int recieveFirst()
{
char input[5] = {"\0"};
cin.get(input , 5);
if(isalpha(input[0]))
{
if(input[0] == 'h' || input[0] == 'H')
{
help();
}
elseif(input[0] == 'n' || input[0] == 'N')
{
startNewGame();
return 1;
}
else
{
cout << "Not a recognized response. Please type 'H' for help or 'N' to start a new game.";
recieveFirst();
}
}
else
{
cout << "Not a recognized response. Please type 'H' for help or 'N' to start a new game.";
return 0;
}
return 1;
}
On line 21, I want to start the function again, so that the user can input the correct respone. The output rather looks something like this:
Not a recognized response. Please type 'H' for help or 'N' to start a new game.
Not a recognized response. Please type 'H' for help or 'N' to start a new game.
The second line, is within the else statement for the first if.
after those two it ends!
Why is this happening?
Why does it not wait for the input when the function is called again?
EDIT: This obviously only happens when the user does not enter an N or H.