Home > Back-end >  Consult the while loop to remove excess input problem
Consult the while loop to remove excess input problem

Time:12-05

Novice small white, consult two while loops, should remove excess input, but don't know what is the difference between, sometimes 2 also can use way, sometimes it is necessary to use a,
A:
 while (cin & amp; & Cin. The get ()! ) 
='\ n'{
continue;
}


The second way:
 while (cin. The get ()! ) 
='\ n'{
continue;
}


For example:
 while (cin. The get ()! ) 
='\ n'{
continue;
}
if (! Cin)
{
break;
}


With the way two, enter a blank line will be stuck, one must use way,

CodePudding user response:

Cin. The clear ();
Cin. Sync ();

CodePudding user response:

While (cin & amp; & Cin. The get ()! )='\ n' & amp; & In front of cin the purpose which teachers explain to help? Is not effect removed in some places, there are times when you must write. A little hard to understand, thank you very much
  • Related