Greetings to everyone!
Firstly, I must apolagize for my English, I'm learning.
What I have to do is the hangman game the simplest way as possible.
This is the code I have at the moment:



Code:
#include <iostream>
using namespace std;
int main()
{
char a,intro;
char word[]={};
char sol[]={};
int i,j,attempts=0;

cout<<"Introduce a sentence:"<<endl;
gets(word);
cout<<"Introduce the attempts number"<<endl;
cin>>attempts;
for(i=0;i<25;i++)
  cout<<endl;


i=0;
while(word[i]!='\0')
i++;

cout<<"You have "<<attempts<<" attempts"<<endl;

cout<<"You have "<<i<<" letters"<<endl;
for(j=0;j<i;j++)
{
  sol[j]='*';
  cout<<"*";
}
cout<<endl;
sol[j]='\0';

a=getchar();


cout<<"Introduce a letter: ";
a=getchar();


intro=getchar();
for(j=0;j<i;j++)
  if(palabra[j]==a)
   sol[j]=a;

cout<<endl;
for(j=0;j<i;j++)
 cout<<sol[j];
cout<<endl;

cin>>a;
}



But it doesn't work correctly, so my doubt is: how could I do it so that the number of attempts subtracts one number when I fail a letter and the game ends when you run out of attempts?
(I don't know if I've explained well, any question ask me)

Important: I have to complete the exercise just with the structure it appears in the code I've done, only with the library <iostream>.

¿Could you help me? Thank you so much!