It’s best to test for decimal numeric digits themselves instead of letters. isdigit.
#include <ctype.h>
if(isdigit(variable))
{
//valid input
}
else
{
//invalid input
}
More Related Contents:
- Determine if char is a num or letter
- How to scanf only integer and repeat reading if the user enters non-numeric characters?
- Determine if a C string is a valid int in C
- "." or "->" C struct accessor [duplicate]
- How to print Number Like following format in c? [closed]
- Access of register STM32 CAN communication
- The most efficient way to implement an integer based power function pow(int, int)
- warning: implicit declaration of function
- What is the difference between char * const and const char *?
- Easy way to use variables of enum types as string in C?
- Map a 2D array onto a 1D array
- Dynamic memory access only works inside function
- String literals: pointer vs. char array
- How does kernel get an executable binary file running under linux?
- C function pointer casting to void pointer
- Using strtok() in nested loops in C?
- __attribute__((constructor)) equivalent in VC?
- Building a kernel module from several source files which one of them has the same name as the module
- Poster with the 8 phases of translation in the C language
- Why didn’t gcc (or glibc) implement _s functions?
- Is the compiler allowed to recycle freed pointer variables?
- Xml validation using XSD schema
- How to change a variable in a calling function from a called function? [duplicate]
- C function defined as int but having no return statement in the body still compiles
- plain C: opening a directory with fopen()
- When is an array name or a function name ‘converted’ into a pointer ? (in C)
- Find maximum of three number in C without using conditional statement and ternary operator
- How to calculate size of array from pointer variable?
- Process Linkage Table and Global Offset Table
- What API do I call to get the system uptime?