Basically my whole program nearly works correctly, however i have made an if statement so if anyone enters anything other then a lowercase letter for the input of guess, it will tell print out something and then take them to the start of the while loop on line 78. However, instead it just executes the line 110 if statement
Thankyou to anybody who helps in advance :)
PS: I have no idea what code tags are so sorry if i haven't used them.
/* USER INTERFACE GOES HERE. COMPLETE THIS SECTION */
cout << "Welcome to hangman!\nThe aim of the game is to guess letters in a word.\nEach underscore represents a letter!" << endl; // Line of code that explains the game to the user
for (int x = 0; x <= guessWord.length(); x++)
{ // this for loop prints out how many underscores there are for every letter
cout << guesses[x] << " ";
}
cout << endl << "You have 5 lives to start off with!" << endl; // So the user knows how many lives he starts with
cout<<"PLEASE ONLY ENTER LOWERCASE LETTERS!"<<endl; // I am asking the user to only print out lowercase letters otherwise the program will not work correctly
while (running == true)
{
cout << endl << endl;
cout << "Please enter your guess : \n";
// Where the user inputs there guess every time
cin >> guess;
if (guess == 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z')
{
bool test = false;
for (int i = 0; i <= guessWord.length(); i++)
{
if (guessWord[i] == guess)
{
guesses[i] = guess;
for (int x = 0; x <= guessWord.length(); x++)
{
cout << guesses[x] << " ";
}
cout << endl << endl << "Correct!" << endl << endl; // To let the user know that the letter they guessed is correct
cout << "You have " << lives << " lives remaining!\n" << endl; // Code shows how many lives the user has left every guess
test = true;
}
}
static int counter = 0;
if (test == false)
{
lives--;
lettersGuessed[counter] = guess;
counter++;
cout << "\nWrong!" << " You have " << lives << " lives remaining!" << endl; // Code shows how many lives the user has left after every guess