uhmm??...

Pages: 12
ok i seem to get it, but what if the user accidentally inputs something different, how will i inform that user that he made a mistake, (in a mix of ur code and mine)
note: rewriting my code again
You could output your message just before the do-while loop, check.

1
2
3
4
5
6
7
8
9
10
		//Key the key pressed by the user.
		key = _getch();

		//Add a check and a message here.
		if( key != 13 )
			std::cout << "Invalid key pressed to exit...\n";       
	
	}while( key != 13 );
	//13 is ascii for the key [ENTER].
	//There's a link below. 


Do forget, you can also check ranges etc. It doesn't have to be a key press.
1
2
3
4
5
6
7
8
do
{
	int number = 0;

	//Get input here...

	//Check within a loop.
}while( ( number > 0 ) && ( number < 6 ) ) //number is greater than 0 and less than 6. 1-5 
Topic archived. No new replies allowed.
Pages: 12