Quote:
Originally posted by Mingzhi
What I do not understand is, why it give me this when I typed a letter for cin>>previous_balance
Enter the last name for the ... customer
.
.
.
.
.
it will just flood the screen and keep repeating the same sentence above. I know that previous balance is a float, but i am just checking it to make sure it is really entered as a float. I have tried putting cin.get(): before every cin. However, it still give me the same problem.
If you try to read an invalid input (e.g. a letter when expecting a number) the stream goes into an error state; the number you get back is undefined. You need to check for the error state and recover from it before you can do anything else.