Whenever I enter an incorrect answer (main()) then it keeps looping and having this output without stopping to std::cin. Usually std::getline would fix this but I can't do that sense it's integers and not strings.
#include <iostream>
#include <string>
#include <math.h>
int Check();
void PrintOut(int Quotient, int Remainder);
double Minutes;
int main(){
while(true){
std::cout << "How many minutes?: ";
std::cin >> Minutes;
if(std::cin.fail()){
std::cout << "Enter a number, try again.\n\n";
}
else{
break;
}
}
Check();
return 0;
}
Output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
How many minutes?
Enter a Number try again.
How many minutes? Enter a number, try again.
How many minutes? Enter a number, try again.
How many minutes? Enter a number, try again.
How many minutes? Enter a number, try again.
How many minutes? Enter a number, try again.
How many minutes? Enter a number, try again.
How many minutes? Enter a number, try again.
How many minutes? Enter a number, try again.
How many minutes? Enter a number, try again.
How many minutes? Enter a number, try again.
How are you clearing the error flag? Once the stream enters an error state it will stay in the error state until the error is cleared and any offending data is removed from the input buffer.