views:

253

answers:

1

I want to allow the user to use lowercase or uppercase letters giving the value to the char type variable... Any help??

A: 

Err, do you mean something like (where getAChar() is whatever method you're using to get the character):

int ch = getAChar();
while (!isalpha (ch))
    ch = getAChar();

Alternatively, if you want to check that a user enters only alphas. You can get a string with:

cin >> myString;

Checking for alphas is as simple as:

char *cstr = myString.c_str();
for (int i = 0; i < myString.length(); i++)
    if (!isalpha (*cstr++))
        return false;
return true;
paxdiablo