Answers for "integer type validation c++"

C++
1

integer type validation c++

cout << endl << "Introduce an integer: ";
p = scanf("%d", &x);       //Scanf returns a false when the value doesn't match the correct format.
getchar();

while (p == false)
{   cout << endl << "You didn't introduce an integger. Try again.";

 	cout << endl << "Introduce an integer: ";

    p = scanf("%d", &x);
  	getchar();
}
Posted by: Guest on November-04-2020

Browse Popular Code Answers by Language