Do Nothing Command?

Is there a "Do Nothing" command in c++? As in, when you press the wrong key it just sits there and waits for the user to input the right key? It doesn't write anything, exit the program, or anything like that.

Thanks,
-Timmah \m/
A common way is to read from stdin (usually the keyboard) within a while loop, with the condition checking what the user types and breaking the loop when they type the right thing.

I expect someone will come along soon to recommend system("PAUSE"); - it's worth looking that up to see why it's such a bad idea.
For the above you'll have to write a loop in which you read from the input, check if it's correct and if not read again
eg:
1
2
3
4
char c;
do
   cin.get ( c ); // keep reading c
while ( c != 'x' ); // until reads an x 


A 'do nothing statement' can be represented by a semicolon or a pair of braces without anything useful within them:
1
2
3
4
5
6
if ( x )
    ;  // do nothing
if ( y )
{
    // do nothing
}
cool - thanks guys!

:D
Topic archived. No new replies allowed.