integer type validation c 2b 2b

Solutions on MaxInterview for integer type validation c 2b 2b by the best coders in the world

showing results for - "integer type validation c 2b 2b"
Candy
15 Jan 2016
1cout << endl << "Introduce an integer: ";
2p = scanf("%d", &x);       //Scanf returns a false when the value doesn't match the correct format.
3getchar();
4
5while (p == false)
6{   cout << endl << "You didn't introduce an integger. Try again.";
7
8 	cout << endl << "Introduce an integer: ";
9
10    p = scanf("%d", &x);
11  	getchar();
12}