Search
 
SCRIPT & CODE EXAMPLE
 

CPP

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();
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: tic toc toe c++ 
Cpp :: array 2d dynamic allocation c++ 
Cpp :: c++ int to string 
Cpp :: convert int to string c++ 
Cpp :: minimum spanning trees c++ 
Cpp :: c++ code for insertion sort 
Cpp :: c++ ros publisher 
Cpp :: g++ optimization flags 
Cpp :: c++ declaring and initializing strings 
Cpp :: convert long int to binary string c++ 
Cpp :: wine linux 
Cpp :: maximum int c++ 
Cpp :: c++ find element in vector 
Cpp :: c++ string comparison 
Cpp :: cpp unions 
Cpp :: string to vector char c++ 
Cpp :: singleton c++ 
Cpp :: ue4 c++ enumaeration 
Cpp :: c++ call method in same class 
Cpp :: for loop in c++ 
Cpp :: initialize an array in c++ 
Cpp :: remove element from array c++ 
Cpp :: delete specific row from dynamic 2d array c++ 
Cpp :: file c++ 
Cpp :: reverse function in cpp string 
Cpp :: c++ pause linux 
Cpp :: concat two vectors c++ 
Cpp :: team fortress 
Cpp :: ascii conversion cpp 
Cpp :: c++ input 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =