CKTIS / C
atoll — C23 library function
`atoll(const char *nptr)` from `<stdlib.h>` converts an initial decimal integer and returns `long long int`. It skips white space, recognizes an optional sign, and ends at the first nonmatching character.
Version: C23
Syntax
long long int atoll(const char *nptr);atoll(const char *nptr) from <stdlib.h> converts an initial decimal integer and returns long long int. It skips white space, recognizes an optional sign, and ends at the first nonmatching character.
It suits previously validated wide counters such as byte counts or timestamps when an integer type of at least 64 bits is needed. The example really converts "9000000000B" and prints 9000000000 through %lld.
No digits gives an ambiguous 0. A result outside LLONG_MIN..LLONG_MAX has undefined behavior in C23, and nptr must not be NULL, so atoll cannot safely probe the boundary. Use strtoll, its end pointer, and errno.
Examples
#include <stdio.h>
#include <stdlib.h>
int main(void) {
long long bytes = atoll("9000000000B");
printf("%lld\n", bytes);
return 0;
}
Result
9000000000
It suits previously validated wide counters such as byte counts or timestamps when an integer type of at least 64 bits is needed. The example really converts `"9000000000B"` and prints `9000000000` through `%lld`.