#include <stdlib.h>unsigned long int strtoul(const char *start, char **end, int radix);
The strtoul( ) function converts the string representation of a number stored in the string pointed to by start into an unsigned long int and returns the result. The base of the number is determined by radix. If radix is zero, the base is determined by the rules that govern constant specification. If the radix is specified, it must be in the range 2 through 36.
In C99, start and end are qualified by restrict.
The strtoul( ) function works as follows. First, any whitespace in the string pointed to by start is stripped. Next, each character that comprises the number is read. Any character that cannot be part of an unsigned integer number will cause this process to stop. This includes whitespace, punctuation, and characters. Finally, end is set to point to the remainder, if any, of the original string. This means that if strtoul( ) is called with “ 100 Pliers”, the value 100L will be returned, and end will point to the space that precedes “Pliers”.
If the result cannot be represented as an unsigned long integer, ULONG_MAX is returned and the global variable errno is set to ERANGE, indicating a range error. If start does not point to a number, no conversion takes place and zero is returned.
Related functions are strtol( ) and strtoull( ).