I have a program that reads integers from a file and assigns them to certain variables. I have this block of code below to error check the information that is coming from the file. If the information is not a positive integer, the if statement is supposed to catch it and reset the variable and io stream.
int quantity;
input >> quantity;
if(input.fail() || (quantity < 0)){
quantity = 0;
input.clear();
input.ignore(200, ' ');
}
However, if the information is a double, then it doesn't enter this block of code and the rest of my program stops working properly. How do I get my program to enter the if statement when a double shows up in my file?