Answers for "convert string to int error checking c"

C
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"

Browse Popular Code Answers by Language