How to trap an error
Posted on 2002-03-17
I have declared a variable as integer and i make some calculations based on the user input..I have taken care of negative numbers but how to trap if the user enters anything other than a number...
here is the sample code which i have used..
cout << "Choose a option of your choice: \n";
cin >> selection;
cerr << "Invalid selection \n";
cout << " You have entered a negative selection " << amount << "\n";
cout << " Invalid selection: " << amount << "\n";