Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

convert string to int error checking c

const char *number = "10";
char *end;
long int value = strtol(number, &end, 10); 
if (end == number || *end != '' || errno == ERANGE)
    printf("Not a number");
else
    printf("Value: %ld", value);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #convert #string #int #error #checking
ADD COMMENT
Topic
Name
9+3 =