C++: Do I need to use cin.get() before I use cin.ignore? -


what cin.ignore (100, '\ n') works Will the use of cin through stream?

Example:

  cin> & Gt; Temporary; // Enter the key input if (cin.fail ()) {cin.clear (); Cin.ignore (100, '\ n'); }   

Or do I have to use cin.get ()?

Example:

  temp = cin.get (); If (cin.fail ()) {cin.clear (); Cin.ignore (100, '\ n'); }   

Will these codes give the same results?

Ah, stupid me, I made a function to make clearing calls

  Zero clear () {cin.clear (); Cin.ignore (100, '\ n'); }   

And in my program, it is called the function clear () more than once in those cases where clear () It was called twice in the row without input from the angle, it was prompted for input in a blank line.

I'm guessing this,

Comments