atol(3)

atol3

Convert ascii string to long or long long integer

Usage

#include <stdlib.h>

long

atol(const char *nptr);

long long

atoll(const char *nptr);

Library

Standard C Library (libc, -lc)

Overview

The atol() function converts the initial portion of the string pointed to by nptr to long integer representation.

It is equivalent to:

strtol(nptr, (char **)NULL, 10);

The atoll() function converts the initial portion of the string pointed to by nptr to long long integer representation.

It is equivalent to:

strtoll(nptr, (char **)NULL, 10);

Compatibility

The FreeBSD implementations of the atol() and atoll() functions are thin wrappers around strtol() and strtoll() respectively, so these functions will affect the value of errno in the same way that the strtol() and strtoll() functions are able to. This behavior of atol() and atoll() is not required by ISO/IEC 9899:1990 (“ISO C90”) or ISO/IEC 9899:1999 (“ISO C99”), but it is allowed by all of ISO/IEC 9899:1990 (“ISO C90”), ISO/IEC 9899:1999 (“ISO C99”) and IEEE Std 1003.1-2001 (“POSIX.1”).

Errors

The functions atol() and atoll() may affect the value of errno on an error.

Releases

87 releases since FreeBSD 2.0.5-RELEASE; the text changed 39 times.

  1. 2.0.5–3.4
  2. 3.5–3.5.1
  3. 4.0
  4. 4.1–4.2
  5. 4.3–4.4
  6. 4.5–4.11
  7. 5.0–6.3
  8. 6.4
  9. 7.0
  10. 7.1
  11. 7.2
  12. 7.3
  13. 7.4
  14. 8.0
  15. 8.1
  16. 8.2
  17. 8.3
  18. 8.4
  19. 9.0
  20. 9.1
  21. 9.2
  22. 9.3
  23. 10.0
  24. 10.1
  25. 10.2
  26. 10.3
  27. 10.4
  28. 11.0
  29. 11.1
  30. 11.2
  31. 11.3
  32. 11.4
  33. 12.0
  34. 12.1
  35. 12.2
  36. 12.3
  37. 12.4
  38. 13.0–13.2
  39. 13.3–14.5
  40. 15.0–16.0

Standards

The atol() function conforms to ISO/IEC 9899:1990 (“ISO C90”). The atoll() function conforms to ISO/IEC 9899:1999 (“ISO C99”).

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.