string hidden(word.length(), '_');
cout<<"Guess the right word by typing one letter every one try."<<endl;
cout<<"You have "<<tries<< "tries to guess the word.";
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
while (y<tries)
{
cout<<"n\n"<<hidden;
cout << "\n\nGuess a letter: ";
cin >> letter;
if((fill(letter, word, hidden) == 0))
{
cout<<"Whoops!! That letter is not there."<<endl;
y++;
}
else
{
cout<<"You found a letter"<<endl;
}
cout<<"You have "<<tries-y<<"left"<<endl;
if (word==hidden)
{
cout<<word<<endl;
cout<<"You save yourself from being hanged"<<endl;
cout<<"You win!!"<<endl;
system("pause");
return 0;
}
}
if (y==tries)
{
cout << "\nYou lose!! You've been hanged." << endl;
cout << "The word was : " << word << endl;
}
cin.ignore();
cin.get();
return 0;
Sorry in advance if I sound harsh but for a start you might like to use code tags and tidy up your blank lines and lack of indentation which makes you look as though you take no pride in your work. Your presentation is like a mad-womans @#$t
Once you overcome that hurdle you might like to consider 'fill' in all it's threefold lack of symmetry. :)