how to check if a string is a number 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: check if string in string c
if(strstr(sent, word) != NULL) {
/* ... */
}
Example 3: how to know if a number is even in c
if((x & 1) == 0)
printf("EVEN!\n");
else
printf("ODD!\n");