Is there a function for cin that will flush it?
My program is in an endless loop for some reason. I'm in the debugging process. Basically, in a loop structure, the user is asked to enter int numbers and no error checking is done. The user could just as well type in a char value. When they do that's when the loops starts. Let's say I type in "A1". Cin will read the first character to put in int x; only to find it's not an int, so x remains the same and cin sets it state to false. Since this is all inside a loop, the step is repeated, only this time it doesn't stop to ask the user to enter a new int since cin is still in the false state.
My program is in an endless loop for some reason. I'm in the debugging process. Basically, in a loop structure, the user is asked to enter int numbers and no error checking is done. The user could just as well type in a char value. When they do that's when the loops starts. Let's say I type in "A1". Cin will read the first character to put in int x; only to find it's not an int, so x remains the same and cin sets it state to false. Since this is all inside a loop, the step is repeated, only this time it doesn't stop to ask the user to enter a new int since cin is still in the false state.
Comment