"1234" ==> 1234 (char * ==> int)

Guy Harris guy at auspex.auspex.com
Thu Dec 20 06:01:32 AEST 1990


>Use the atoi() or atol() function from the C library.

Or, if you have it, "strtol()" (if you have ANSI C, you have it; even if
you don't have ANSI C, you may have it).  "strtol()" has the advantage
that it tells you where it stopped scanning the string, so you can check
whether the string was a number or just started out as one (e.g., you
may not want to just convert "1234motorway" into 1234; you may want to
let the user know that it's not a number).



More information about the Comp.lang.c mailing list