Converts strings of ASCII characters to the appropriate numeric values.
#include <stdlib.h> long int strtol (const char *nptr, char **endptr, int base);Function Variants This function also has variants named _strtol32 and _strtol64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.8 for more information on using pointer-size-specific functions.
Leading zeros after the optional sign are ignored, and 0x or 0X is ignored if the base is 16.
If base is 0, the sequence of characters is interpreted by the same rules used to interpret an integer constant: after the optional sign, a leading 0 indicates octal conversion, a leading 0x or 0X indicates hexadecimal conversion, and any other combination of leading characters indicates decimal conversion.
Truncation from long to int can take place after assignment or by an explicit cast (arithmetic exceptions not withstanding). The function call atol (str) is equivalent to strtol (str, (char**)NULL, 10).
x | The converted value. |
LONG_MAX or LONG_MIN | Indicates that the converted value would cause an overflow. |
0 | Indicates that the string starts with an unrecognized character or that the value for base is invalid. If the string starts with an unrecognized character, *endptr is set to nptr. |
Converts strings of ASCII characters to the appropriate numeric values. strtoll is a synonym for strtoq.
#include <stdlib.h> __int64 strtoq (const char *nptr, char **endptr, int base); __int64 strtoll (const char *nptr, char **endptr, int base);Function Variants This function also has variants named _strtoq32/_strtoll32 and _ strtoq64/_strtoll64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.8 for more information on using pointer-size-specific functions.
Leading zeros after the optional sign are ignored, and 0x or 0X is ignored if the base is 16.
If base is 0, the sequence of characters is interpreted by the same rules used to interpret an integer constant: after the optional sign, a leading 0 indicates octal conversion, a leading 0x or 0X indicates hexadecimal conversion, and any other combination of leading characters indicates decimal conversion.
The function call atoq (str) is equivalent to strtoq (str, (char**)NULL, 10).
x | The converted value. |
__INT64_MAX or __INT64_MIN | Indicates that the converted value would cause an overflow. |
0 | Indicates that the string starts with an unrecognized character or that the value for base is invalid. If the string starts with an unrecognized character, *endptr is set to nptr. |