C
onverts a string to a long long integer value.
#include <stdlib.h> long long strtoll(const char *nptr, char **endptr, int base); #include <wchar.h> long long wcstoll(const wchar_t *nptr, wchar_t **endptr, int base);
nptr
endptr
base
strtoll expects nptr
to point to a string with this form:
[whitespace][sign][0][{x|X}][digits]
These functions stop reading the string at the first character they cannot recognize as part of a number. This may be the null character \0 at the end of the string. With strtoll, this terminating character can also be the first numeric character greater than or equal to base. If endptr
is not a null pointer, a pointer to the character that stopped the scan is stored at the location pointed to by endptr
.
If no conversion can be performed (no valid digits are found or an invalid base is specified), the value of nptr
is stored at the location pointed to by endptr
.
Base | Description |
---|---|
Between 2 and 36 | Base used as the base of the number. |
0 | The initial characters of the string pointed to by nptr determine the base. |
1st char = 0 and 2nd char not = x or X | The string is interpreted as an octal integer; otherwise, it is interpreted as a decimal number. |
1st char = 0 and 2nd char = x or X | The string is interpreted as a hexadecimal integer. |
1st char = 1 through 9 | The string is interpreted as a decimal integer. |
a through z or A through Z | Are assigned the values 10 through 35; only letters whose assigned values are less than base are permitted. |
strtoul allows a plus (+) or minus (-) sign prefix; a leading minus sign indicates that the return value is negated.
strtoll
returns the value represented in the string nptr
, except when the representation would cause an overflow, in which case it returns LONG_MAX
or LONG_MIN
. strtoll
returns 0 if no conversion can be performed.
wcstoll
returns values analogously to strtoll
. For both functions, errno
is set to ERANGE
if overflow or underflow occurs.
tchar.h routine |
_UNICODE not defined |
_UNICODE defined |
---|---|---|
_tcstoll | strtoll | wcstoll |
Versions | Defined in | Include | Link to |
---|---|---|---|
INtime 3.0 INtime 6.0 (wide-character and generic text versions) |
intime/rt/include/stdlib.h intime/rt/include/wchar.h intime/rt/include/tchar.h |
stdlib.h wchar.h tchar.h |
clib.lib |