STRTOUL - convert string to unsigned long integer.

(ANSI Standard)

Usage:

#include <stdlib.h>
uli = strtoul( s, p, base );

Where:

const char *s;
is the string to be converted into an unsigned long integer. This string may consist of any number of blanks and/or tabs, possibly followed by a sign, followed by a string of digits.
char **p;
points to a pointer that will be set to the character immediately following the unsigned long integer in the string "s". If no integer can be formed from "s", "strtoul" makes "*p" point to the first character of "s". If "p" is the NULL pointer, this sort of action does not take place.
int base;
is the base for the number represented in the string. A "base" of zero indicates that the base should be determined from the leading digits of "s". The default is decimal, a leading '0' indicates octal, and a leading '0x' or '0X' indicates hexadecimal.
unsigned long uli;
is the unsigned long integer obtained from "s".

Examples:

#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  */

Description:

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

See Also:

expl c lib strtol

Copyright © 1996, Thinkage Ltd.