short howMany=0;
cout<<"How many student grade details you want to calculate"<<endl;
cin>>howMany;
// now, here how can I check that user's input is integer or not?
Asked
Active
Viewed 127 times
0
-
1The user's input is **not** an integer. It's a sequence of characters. The question is whether that sequence of characters can be **converted** to an integer value. Don't skip that conversion step when you're thinking about input. – Pete Becker Oct 07 '19 at 13:09
1 Answers
-1
now, here how can I check that user's input is integer or not?
if(!(std::cin >> howMany))
throw std::runtime_error("failed to read or parse 'howMany'").

Maxim Egorushkin
- 131,725
- 17
- 180
- 271