how to deny numeric input in c++ code example
Example: how to deny string input in c++
while( ! cin >> x){ //While cin failed to stream the data; Reads input then checks if cin has failed
//Alternative:
/*
cin >> x;
while(cin.fail()){
*/
cin.clear(); //Reset the flags, so you can use cin again
cin.ignore(100, '\n'); //Empty the buffer
cout << "Please enter a number!\n";
/* If alternative is used:
cin >> x; //Read input again
*/
}