If you ask the user to enter a number (with cin >> or scanf, etc), only number can be entered. Non-numeric character simply remains unprocessed, and you're expected to write code that either ignores it, or reads it off into a non-number variable.
#include <iostream>
#include <string>
#include <limits>
usingnamespace std;
int main()
{
cout << "Please, enter a number\n";
int n; // n is a number, it cannot be anything else
// cin >> n reads a number. If the input is not a number,
// it does not read it at all, it sets the error flag on cin and retunrs it
// so we check that condition in a loop:
while( !(cin >> n) )
{
cout << "You need to enter a number\n";
cin.clear(); // reset the error flags
// here you still have unprocessed input. You have options:
// 1. ignore:
cin.ignore(numeric_limits<streamsize>::max(), '\n');
// 2. read into a string
// string str;
// getline(cin, str);
// 3. read into char (in a loop, since there may be many)
// char c;
// while(cin.get(c) && c != '\n')
// {
// }
}
cout << "Thank you for entering the number " << n << '\n';
}