How to exit when different data type is entered.

Hello

I'm currently trying to write a program that prompts the user to enter alphabets (letters: a, b, c, d etc..) and the program will output an error msg when a number (int or float) is entered. I've been searching the web...but I don't really have the syntax for it.

For example:

char mystr;
cin >> mystr;
while (mystr == (int))
{
"Error"
}

Also, is there a way to do multiple assignments within one loop, for example:

if (mystr == 'A', 'B', 'C')
cout << "Hello";

thanks
isalpha


/////////////////////////////////////////////
char mystr;
cin >> mystr;
while (isalpha(mystr))
{
cout<<"Error"<<endl;
cin >> mystr;
}
Also, is there a way to do multiple assignments within one loop, for example:
First: It is comparison not assignment. Second: No, but there is the function isalpha(...):

http://www.cplusplus.com/reference/cctype/isalpha/?kw=isalpha
Topic archived. No new replies allowed.