im trying to write code for my previous boss but can not seem to get the program to be "idiot" proof.
im wanting to have multiple checks so that when someone inputs 'a' into a float (count) it will give me an error so it will allow the user to go back and fix mistakes before it throws the rest of the program off.
program runs fine until it hits the check to see if the value input was a char then it goes into the while loop and outputs "ERROR...." infinitly
shouldnt the !cin be able to tell if the input was of an invalid type or is there something im missing?
also have tried !count to see if that would give desired results and no luck
ive been able to test char to see if they are a certain letter and if an input file is valid but im unable to apply the same logic to test to see if the input is a float or not
here is code snip of the problem
{variable types predefined at begining of main
float count;
string item;
}
cout<< "Enter in the amount of " <<item<< " in store"<<endl;
cin>>count;
while(!cin)
{
cin.clear();
cout<<"ERROR!!! Please enter the correct amount of "<<item<<endl;
cin>>count;
}
yea im using it (system("pause")) to get echo prints but its saving everything to a file so that way i can help my old boss keep a inventory of critical items at his store. very basic code but will be able to give him a good estimate for his food cost to help with bonuses