string zu int c code example
Example 1: string to int c
atoi(str) is unsafe
This is the prefered method:
(int)strtol(str, (char **)NULL, 10)
Example 2: 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;
}