Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

atol - convert string to long integer

&pagelevel(4)&pagelevel

Description

atol() converts an EBCDIC string to which str points into an integer of type long. The string to be converted may be formatted as follows:

[tab ...][+|-]digit...

All characters that produce white space are legal for tab (see the definition under isspace()).

The atol(str) function differs from strtol(str,(char**)NULL,10) only in error handling.

Return val.

Integer value of type long

for strings formatted as described above and representing a numeric value

0             for strings that do not conform to the syntax described above.

LONG_MAX or LONG_MIN

in the case of an overflow, depending on the sign.

Notes

atol() is completely contained in strtol(). However, the function continues to be offered because it is used in many existing applications.

atol() also recognizes strings that begin with digits but then end with any character.
atol() cuts off the numeric part, converts it according to the above description, and ignores the rest.

See also

atof(), atoi(), strtod(), strtol(), strtoul(), stdlib.h.