Hello guys

I have a question about.
if a program asks the user to input a number,
but the user enters a character,
the istream is in error state, am I correct?
my question is, how do I clear it?

Code:
 #include <iostream>
using namespace std;

int main()
{
   
    short num;
    
    cout << "Enter a number: " << endl;
    cin >> num;
   
    cin.clear(); 
    cout << "Enter a number again: " << endl;  // line A.
    cin >> num;

    return 0;
    }
for example,
if I input numbers greater than the size of short,
line A works and waits for an input,
but if I enter any characters,
line A displays but it does not wait for the input and just exits the program.

why is that?

thanks for the help.