checking is a string is anumber in c code example
Example 1: c string is int
int isNumber(char s[])
{
for (int i = 0; s[i]!= '\0'; i++)
{
if (isdigit(s[i]) == 0)
return 0;
}
return 1;
}
Example 2: c check if char is number
char c = 'a'; // or whatever
if (isalpha(c)) {
puts("it's a letter");
} else if (isdigit(c)) {
puts("it's a digit");
} else {
puts("something else?");
}