O'Reilly logo

Advanced UNIX Programming by Warren W. Gay

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The strtol(3) and strtoul(3) Functions

The function sscanf(3) calls upon the functions strtol(3) and strtoul(3) to carry out its dirty work. You can go right to the source by calling them. The synopses for strtol(3) and strtoul(3) are as follows:

#include <stdlib.h>
#include <limits.h>

long strtol(const char *nptr, char **endptr, int base);

unsigned long strtoul(const char *nptr, char **endptr, int base);

Macros from <limits.h> :
    LONG_MAX
    LONG_MIN
    ULONG_MAX
    LONGLONG_MAX
    LONGLONG_MIN
    ULONGLONG_MAX

The function strtol(3) converts a possibly signed integer within a character string to a long integer data type value. The function strtoul(3) is functionally identical, except that no sign is permitted, and the returned conversion value is an unsigned ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required