C ++ type int error handling Input
#include <the iostream> #include <stdio.h> the using namespace STD; int main () { int n-; char CH; the while ( to true ) { COUT << " enter an integer int type: " ; // if the non-input int type IF (! (CIN >> n-)) { // clear the buffer the while ((CH = getchar ()) =! ' \ n- ' ) Continue ; // print error message cout << " Please enter int type !!! " << endl; the Continue ; } cout << " integer you entered was: " << the n-<< endl; } }