C Programming/stdlib.h/strtol

strtol is a function in the C programming language that converts a string into a long integer. stands for string to long. It is included in the C standard library header file. Its prototype is as follows:

The  argument points to a string, represented by an array of characters, containing the character representation of a signed integer value. The string must be null-terminated. The  argument specifies the number base to use, from 2 to 36. If the number base is greater than 10, alphabetic characters ( up to  ) are used as digits in the representation. After the conversion, the value pointed to by  is set to point to the character following the last valid numeric character in the string and the converted integer value is returned. If the string does not contain a valid numerical sequence, zero (0) is returned and the global variable  is set to.

There also exist similar variants of these function named,   and   which parses and returns an integer of the type  ,  , and   respectively.

Standards conformance
The strtol function is part of the ISO standard C library (C89, 1989), and the strtoll function was added as part of the C99 library (1999). It was added to the standard C library as a more well-behaved replacement for the existing atoi function.