OK - I'm sure this is something really simple that I'm missing, but I've spent the past two hours trying to figure out why it isn't working to no avail. Hope someone smarter than I can spot my error.
What I'm trying to do is check a user's input to ensure it is either y/Y or n/N. I'm finding, however, that regardless of the input it doesn't exit the do...while loop.
Below is a greatly simplified version of what I'm trying to do. If anyone could point me in the right direction on this I'd really appreciate it.
The condition (continueProgram != 'Y') || (continueProgram != 'N') is always true!
If continueProgram = 'Y' then continueProgram != 'N' is true.
If continueProgram = 'N' then continueProgram != 'Y' is true.
If continueProgram = anything else then both conditions are true!
Don't you want just while (continueProgram != 'N'); ?
For the input validation I think you want to use && instead of ||
Thanks for the quick response. When you say it that way, it almost makes sense to me!
What I need is to have the loop repeat until either a y/Y or a n/N is entered. I just tried changing the "or" (||) to an "and" (&&) in the code I posted, and it appears to work (although when I did the same thing in my full program, it didn't seem to make a difference).
If anyone has any suggestions on a better way to do this, I'm all ears...
Thanks!
// Going to bed, hoping things will be clearer in the A.M.
OK - just got a chance to look at this again and figured out why my fixed code wasn't working in my main program. Not worth explaining what happened as it was just a stupid mistake on my part that I was overlooking due to staring at the same code for hours.