Please correct me on my translation of this code.
Is the following translation accurate?
Translates to if the data inputed into y doesn't match the data type y was declared as then execute the following statements.Code:#include <limits> // Add this for numeric_limits ... if ( !( cin>> y ) ) { cin.clear(); // Clear the errors cin.ignore ( numeric_limits<streamsize>::max(), '\n' ); cerr<<"Invalid input, try again: "; }
A follow up question is what does the header limits do?
Does it hold the details of the following code?Code:numeric_limits<streamsize>::max()



LinkBack URL
About LinkBacks


