Nov 1, 2014 at 1:21pm
When any value over int is entered (including letters and decimal numbers) the program gets stuck in a loop. How can I fix this?
Thanks
Last edited on Nov 1, 2014 at 1:23pm
Nov 1, 2014 at 1:43pm
Please post the code. It's hard to say without seeing it.
Nov 1, 2014 at 5:10pm
Fixed it with this code thanks to someones post on yahoo answers, I also includes #include <limits>
1 2 3 4 5
|
if (cin.fail())
{
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
|
well decimal numbers still mess it up but I think it's okay.
Last edited on Nov 1, 2014 at 5:13pm