atol function(Convert String to Long Integer) in C Language – example and detail

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 establishing of the string, converts the subsequent characters as section of the number, and then stops when it encounters the first character that isn’t always 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 lengthy integer.

Returns

The atol characteristic returns the long integer representation of a string. The atol function skips all white-space characters at the commencing of the string, converts the subsequent characters as part of the number, and then stops when it encounters the first personality 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 feature can be used in the following versions:

ANSI/ISO 9899-1990

Similar Functions

Other C features that are similar to the atol function:

atof characteristic atoi characteristic strtol characteristic strtoul characteristic

See Also

Other C functions that are noteworthy when dealing with the atol function:

strtod function <stdlib.h>