Assuming by word, you mean a string, which in C, is either a char* or a char[].
Personally I would use atoi()
This function returns the converted integral number as an int value. If no valid conversion could be performed, it returns zero.
Example:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void is_number(char*);
int main(void) {
char* test1 = "12";
char* test2 = "I'm not a number";
is_number(test1);
is_number(test2);
return 0;
}
void is_number(char* input){
if (atoi(input)!=0){
printf("%s: is a number\n", input);
}
else
{
printf("%s: is not a number\n", input);
}
return;
}
Output:
12: is a number
I'm not a number: is not a number
However if you're just checking a single character, then just use isdigit()