Hey guys i need help over in my program. My error is that when i use cin for a int declaration, when i type in a char, they straight away have a infinite loop. I try using the cin.clear() but when i prompt the user to "enter a number again" and place a cin>>num, the program just wont stop at the cin and proceed wth the rest of it or resulting in a error.
Here is the program.
int num;
cout<<"Enter a number: ";
while(!(cin>>num) && !cin.eof())
{
cout<<"Error\n";
cin.clear();
cout<<"Please enter a number again: ";
cin>>num;
}