Answers for "c how to check if string can converted int"

C
4

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;
}
Posted by: Guest on October-25-2020
0

convert string to int error checking c

const char *number = "10";
char *end;
long int value = strtol(number, &end, 10); 
if (end == number || *end != '\0' || errno == ERANGE)
    printf("Not a number");
else
    printf("Value: %ld", value);
Posted by: Guest on July-29-2021

Code answers related to "c how to check if string can converted int"

Code answers related to "C"

Browse Popular Code Answers by Language