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
  • 17,936
  • 3
  • 49
  • 73
Nasrullah
  • 3
  • 2
  • 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
  • 119,842
  • 14
  • 147
  • 239