I want to check that user input is a letter only. I have managed to trap it for lower case vs upper case using this code:
I also want to prompt the user to enter a correct letter in case they choose a number or a symbol. Can this be done the same way by manipulating the ascii table? I have no issue doing that except for the characters between the lower case and uppercase letters....is there a way to isolate those characters using logical operators? I hope I make sense!!
if ("%d" > 64 || "%d" < 91, letter, letter)
letter = letter+32;
Do you mean this code works for you?
Doh!!! Nope doesn't work! It now accepts the upper case letters, but not the lower case letters!!!
Originally Posted by vart
Are you able to point me in the right direction as to what I should be looking for?
the c library already has functions that do this. in ctype.h the tolower function will return the lower case equivalent or the same character if there isn't a lower case equivalent. the toupper function does the opposite of tolower. if you just want to check the case, isupper and islower will do that, and if you want to check for a letter, isalpha does that.
Excellent...thanks for that....Will check now
The "%x" stuff doesn't work for if statements!
Please consult your books again.