HP C/iX Library Reference Manual (30026-90004)
114 Chapter5
HP C/iX Library Function Descriptions
atol
atol
Converts a string to a long integer.
Syntax
#include
long int atol (const char *
str
);
Parameters
str
A pointer to a character string to be converted to an object of type long
int.
Return Values
x A long integer upon successful completion.
0 An error occurred. The
str
argument may have started with an
unrecognized character.
Description
The atol function converts the string of characters that
str
points to into a long integer
(unsigned long int) representation. The atol function skips over white space before
looking for the start of the number. The format of the input string is the same as that
accepted by the %ld scanf format conversion.
This function converts any characters up to, but not after, any unrecognized character it
encounters. In this case, atol returns the number that has been converted up to that
point.
See Also
atof(), atoi(), strtod(), strtol(), strtoul(), scanf(), ANSI C 4.10.1.3, POSIX.1 8.1