Re: Implimenting prompts in program for reinput from user?

  • From: "Dale Leavens" <dleavens@xxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Tue, 20 Jul 2010 07:09:44 -0400

A while loop. this is a good example of what that loop is good for.

Prompt for input;
receive input;
while input is invalid {
display error;
accept new input;
}
.
.
.
continue processing;

Hope this pseudo code helps.

Dale leavens.


----- Original Message ----- From: "Jes" <theeternalkid@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Tuesday, July 20, 2010 6:36 AM
Subject: Implimenting prompts in program for reinput from user?


Say I want a user to enter a number from 1 to 3, but they enter something else, like 4, or the letter v, or whatever. How would I tell the program to display an error message to the user using cout, then return them to the initial prompt?
Thanks.
Jes

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: