I'm trying to write a function that allows a user to enter a name. The name cant be over 10 characters and they need to confirm their username. I don't want the user to put anything other than y or n for their confirmation answer. For some reason the first time it tries to confirm your name, it asks you to re-enter your answer, regardless if it was Y or N. I'm new at this, so it could be a simple problem, but all help will be appreciated.
The issue is with your condition here for the loop:
1 2 3 4 5
while (decision != 'n' || decision != 'N' || decision != 'Y' || decision != 'y')
{
cout << "Please re-enter your answer using Y or N." << endl;
cin >> decision;
}
By using "||" instead of "&&", you're saying that only ONE of those conditions have to be true for the whole thing to be true. So, if you input "n", n is not "N" or "Y" or "y", therefore, the condition will become true. You want to replace "||" with "&&"