ATOL(3POSIX)

πŸ’– ATOL(3POSIX) πŸ’–

okay bestie, we're in the POSIX Programmer's Manual today, and this one's a little baby page about turning strings into big ol' integers. no cap, it's short but it matters, so let's get into it 🫢


✨ PROLOG ✨

so like, heads up before anything else: this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ (so pls consult the corresponding Linux manual page for the details of Linux behavior, bestie, fr fr), or honestly? the interface may not even be implemented on Linux at all. πŸ’€


🌸 NAME 🌸

atol, atoll β€” convert a string to a long integer


πŸŽ€ SYNOPSIS πŸŽ€

#include <stdlib.h>

long atol(const char *nptr);
long long atoll(const char *nptr);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so the functionality described on this reference page is aligned with the ISO C standard. and like, if there's any conflict between the requirements described here and the ISO C standard, that conflict is unintentional β€” no drama intended. this volume of POSIX.1‐2017 defers to the ISO C standard. periodt. πŸ‘‘

except as noted below, the call atol(nptr) shall be equivalent to:

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

and except as noted below, the call to atoll(nptr) shall be equivalent to:

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

the handling of errors may differ. and here's the part where we get serious: if the value cannot be represented, the behavior is undefined. undefined!! not "kinda weird", not "a little off" β€” undefined. so pls know your range, i'm begging πŸ™ˆ


⭐ RETURN VALUE ⭐

these functions shall return the converted value if the value can be represented. that's it, that's the whole vibe πŸ’…


πŸ”₯ ERRORS πŸ”₯

no errors are defined. none. zero. the error list is empty, it's giving minimalist.

the following sections are informative.


🌈 EXAMPLES 🌈

none. (iconic of them honestly, no notes)


πŸ’œ APPLICATION USAGE πŸ’œ

if the number is not known to be in range, you should be using strtol() or strtoll() instead β€” because atol() and atoll() are not required to perform any error checking. so like, they will not catch you if you fall, bestie. know that. 🫢


🧚 RATIONALE 🧚

none.


πŸ“ FUTURE DIRECTIONS πŸ“

none.


πŸ‘‘ SEE ALSO πŸ‘‘

  • strtol()
  • the Base Definitions volume of POSIX.1‐2017, <stdlib.h>

portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. in the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. the original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


and that's the whole page, bestie!! brought to you by IEEE/The Open Group, 2017 β€” ATOL(3POSIX), mwah πŸ’‹πŸ’…βœ¨