I've written a small program, part of the program asks the user to input two numbers. How do I go about testing the numbers to check that the user did input an integer and not a character by accident. I ve tried the folowing:
label:
cout << "Please enter a number: ";
cin >> num1;
cout << "Please enter another number: ";
cin >> num2;
if ((num1 <= 47 || num1 >= 58) || (num2 <= 47 || num2 >= 58))
goto label;
using the goto statement, but if someone does enter a character the program just crashes. Hope somebody has some ideas.
label:
cout << "Please enter a number: ";
cin >> num1;
cout << "Please enter another number: ";
cin >> num2;
if ((num1 <= 47 || num1 >= 58) || (num2 <= 47 || num2 >= 58))
goto label;
using the goto statement, but if someone does enter a character the program just crashes. Hope somebody has some ideas.