strtol — User Commands
NAME
strtol, strtoul − Convert character string to integer
SYNOPSIS
#include <stdlib.h>
long int
strtol(string, endPtr, base)
unsigned long int
strtoul(string, endPtr, base)
ARGUMENTS
char ∗string (in) String containing ASCII representation of integer.
char ∗∗endPtr (out) If not NULL, gives address of pointer to fill in with address of first character in string following integer.
int base (in) Base to use for conversion; see below for explanation. Must be between 0 and 36, inclusive.
DESCRIPTION
The strtol and strtoul procedures convert a character string to its corresponding integer representation and return the integer value. Both procedures expect string to point to a sequence of digits, optionally preceded by any amount of white space (as defined by the isspace procedure). Strtol also permits the digits to be preceded immediately by a minus sign, in which case the result is a negative integer.
If base is between 2 and 36, inclusive, then the permissible “digits” of the string consist of the first base characters in the set 0 through 9 and a through z (or A through Z). The integer result will be calculated using base as the radix for conversion. If the value of base is 16, then the characters 0x or 0X may precede the digits, following the sign if it is present.
If base is 0, then the radix for conversion is chosen based on the initial digits of the number. If the initial digits are 0x or 0X, then base 16 will be used for conversion; otherwise if the first digit is 0 then base 8 will be used for conversion; otherwise base 10 will be used.
Strtol and strtoul convert as many characters as possible from string, and return in ∗endPtr the address of the first character not forming a valid portion of the number. If no conversion could be performed (string was empty, or did not point to a number in the expected form), then string will be stored in ∗endPtr and zero is returned.
KEYWORDS
base, convert, integer, radix, string
Sprite version 1.0 — March 21, 1989