xXshadowXx
June 23rd, 2008, 06:59 PM
Hi, I'm new to the forum, and I'm sorta new to programming, and I have a pretty simple question. (I hope)
I need to know how to handle an error when someone puts something other than a number into a double(like a letter)
Here's a small example:
double a;
cout << "Insert a number: ";
cin >> a;
This is where if a letter is inserted the program starts to flicker and crashes and stuff, if a letter is put in.
So, please someone show me how to catch the input error and maybe re-ask them for the value?
Thanks again!
I need to know how to handle an error when someone puts something other than a number into a double(like a letter)
Here's a small example:
double a;
cout << "Insert a number: ";
cin >> a;
This is where if a letter is inserted the program starts to flicker and crashes and stuff, if a letter is put in.
So, please someone show me how to catch the input error and maybe re-ask them for the value?
Thanks again!