I cannot figure out how to validate a string so that it accepts both uppercase and lowercase letters as in a name. Here is the code:
bool GetString(char buf[])
{
int i;
int length;
bool valid;
cin.getline(buf, 30);
length = strlen(buf);
for (i = 0; i < length; i++)
{
if ((buf[i] >= 'a' && buf[i] <= 'z') || (buf[i] >= 'A' && buf[i] <= 'Z') || (buf[i] >= 'a' && buf[i] <= 'Z') || (buf[i] >= 'A' && buf[i] <= 'z'))
{
valid = true;
}
else
{
valid = false;
}
}
return valid;
}