C Language: atol function
(Convert String to Long Integer)
In the C Programming Language, the atol function converts a string to a long integer.
The atol function skips all white-space characters at the beginning of the string, converts the subsequent characters as part of the number, and then stops when it encounters the first character that isn't a number.
Syntax
The syntax for the atol function in the C Language is:
long int atol(const char *nptr);
Parameters or Arguments
- nptr
- A pointer to a string to convert to a long integer.
Returns
The atol function returns the long integer representation of a string. The atol function skips all white-space characters at the beginning of the string, converts the subsequent characters as part of the number, and then stops when it encounters the first character that isn't a number.
Required Header
In the C Language, the required header for the atol function is:
#include <stdlib.h>
Applies To
In the C Language, the atol function can be used in the following versions:
- ANSI/ISO 9899-1990
Similar Functions
Other C functions that are similar to the atol function:
- atof function <stdlib.h>
- atoi function <stdlib.h>
- strtol function <stdlib.h>
- strtoul function <stdlib.h>
See Also
Other C functions that are noteworthy when dealing with the atol function:
Advertisements