The if statement is completely ignored in this program

.....
Last edited on
Before line 66, add:

std::cin.ignore(10000,'\n');

There's a funny thing when you use cin to input into a character- it only inputs one character. That means that the newline character that you put in when you hit enter to insert the character is still floating in the input stream. Once the code asks for a new string, it reads the newline and terminates the input. What the code I just showed does is ignores everything in the buffer up until and including the newline, or 10000 characters. That way, it rids of that pesky newline causing your problems.
Ah thank you! I will be sure to remember that cin.ignore function. Should be extremely useful.
Topic archived. No new replies allowed.