(ANSI Standard)
#include <stdlib.h> uli = strtoul( s, p, base );
#include <stdlib.h> ... char *p, *s; unsigned long uli; ... s = "123y"; uli = strtoul(s,p,10); /* * At this point, "p" will point at the character 'y' * in the string constant, and "uli" has the value 123. */ uli = strtoul("10",NULL,10); /* assigns 10 to uli */ uli = strtoul("10",NULL,8); /* assigns 8 to uli */
"strtoul" converts the string "s" into an unsigned long integer. Conversion stops with the first character that cannot be part of such a number.
The string to be converted can contain the digits '0' to '9'. Depending on the base, the string can also contain letters representing digits greater than 9. The best known example is hexadecimal which uses '0' to '9' and 'A' to 'F' as digits. An upper case letter has the same value as a lower case one, so "abc" is the same number as "ABC".
Since you have 10 possible digits and 26 letters, the maximum value for the "base" argument is 36.
Copyright © 1996, Thinkage Ltd.