I took everything else not relevant out. I want to avoid the endless repeating of "please enter a command". If a user puts in more than five characters I want the program to ignore it and ask only once to "please enter a new command".
Actually I want it to only accept the following commands "r NNN" or r, space and three integers, p p or p m or q. If these aren't entered I want the program to ignore the command and ask once for the user to "please enter a command".

ignore input if wrong
Arun Narayan
Nick Hart
In that case, please paste what you have tried and what is exactly not working.
Thanks, Ayman Shoukry VC++ TeamMaranello
From a usability point of view it should always be apparent to the user what they should be inputting. If you just ignore invalid input and don't explain what's wrong then whomever is using your program is going to get frustrated with it. If the user continually enters the wrong command you should print out a short usage and then prompt for the command again.
You want to code this as a loop of some kind that stays in that loop until you get valid input but you should print out what you're looking for if your input is in error.