i want to make a error check on each input.
if i only got 1 input.. then i just use while(input==false)
so it will continue ask user to input if he wrong input

but if i have many input,then the while loop will complicated.. for example:
Enter ur gender
Enter ur age
Enter ur address
And so on

so if each input need a while loop then my program is something like this:

while(input1==false)
{
   while(input2==false)
   {
       while(input3==false)
        {
           while(input4==false)
           { 
              ....
           }
        }
    }
}

it is complicated for me to write

So any suggestion to done this?

i want to make a error check on each input.
if i only got 1 input.. then i just use while(input==false)
so it will continue ask user to input if he wrong input

but if i have many input,then the while loop will complicated.. for example:
Enter ur gender
Enter ur age
Enter ur address
And so on

so if each input need a while loop then my program is something like this:

while(input1==false)
{
   while(input2==false)
   {
       while(input3==false)
        {
           while(input4==false)
           { 
              ....
           }
        }
    }
}

it is complicated for me to write

So any suggestion to done this?

Hi,
I think in above case you should use single variable to accept input & then use single while loop to check validity.. If this is not possible in ur case , then simply use & character to check multiple inputs.

Edward needs more information. Can you post the actual code you're using instead of paraphrasing? It's easier to optimize code than guess about what your solution looks like. :)

Maybe the best way to do this would be to error check after each input, then move on.

while(input1==false)
{
cin>>input1
}
while(input2==false)
{
...

This article has been dead for over six months. Start a new discussion instead.