0
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?
BoBTFish
  • 19,167
  • 3
  • 49
  • 76
Nasrullah
  • 3
  • 3
  • 1
    The 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 Answers1

-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