I have a program which asks the user for a number (float) but if the user inputs a char instead of a float it sends my program into a loop which never ends. I want to know if there is a way to read what the user inputs and if it is a char then it will tell the user they must enter a number and repeats the orginal question.
cout << "enter number";
cin >> x;
if (x != char) // problem is here
cout << "Number is: " << x;
cout << "you must enter a number";