I want to limit the input of the user to integer data only. So I need to validate an integer variable to an extent that it accept only integer data and not alphabetic and special character data. For example, see the code below
int a;
cout << "Enter any number: ";
cin >> a;
Now if the user enter any data other than integer type. It should give the following output without any error
Enter any number: alphabet
Invalid Input! Try again..
Enter any number:
So how do i implement it?