int value = 0; //Create the variable
bool validValue = false; //Set the looping value to false, make it loop
while (!validValue) {
std::cout << "Enter a value: "; //Output asking for info
std::cin >> value; //Read in the presumed integer value
validValue = true; //Presume the value is true
if (std::cin.fail()) { //If the CIN Fails
std::cin.clear(); //Clear the CIN buffer
std::cin.ignore(INT_MAX, '\n'); //Ignore the next output, its not an input
std::cout << "Value was invalid. Try Again"; //Output an error message
value = 0; //Set the value to 0
validValue = false; //The value isn't valid, so loop again
}
}