Check if User Inputs a Letter or Number in C
问题 Is there an easy way to call a C script to see if the user inputs a letter from the English alphabet? I'm thinking something like this: if (variable == a - z) {printf("You entered a letter! You must enter a number!");} else (//do something} I want to check to make sure the user does not enter a letter, but enters a number instead. Wondering if there is an easy way to pull every letter without manually typing in each letter of the alphabet :) 回答1: #include <ctype.h> if (isalpha(variable)) { ..