explain_strtoull_or_die(3)
β¨ explain_strtoull_or_die β¨
okay bestie, so you know how strtoull(3) exists and it's giving "I convert strings to integers" but also it's giving "and I will NOT tell you what went wrong"? yeah. that's where this little icon comes in. welcome to explain_strtoull_or_die(3) from the Library Functions Manual π
πΈ NAME πΈ
explain_strtoull_or_die β convert string to integer and report errors
like. the name literally tells you everything. it converts. it reports. it's a whole package. no cap.
π SYNOPSIS π
#include <libexplain/strtoull.h>
unsigned long long explain_strtoull_or_die(const char *nptr, char
**endptr, int base);
unsigned long long explain_strtoull_on_error(const char *nptr, char
**endptr, int base))
okay first of all: yes, that trailing )) in the second one is really there, I'm not editing it, I don't make the rules, I just report them π
also like, lowkey obsessed with how explain_strtoull_on_error gets two closing parens and _or_die only gets one. main character energy for real.
π¦ DESCRIPTION π¦
the _or_die one π«Ά
The explain_strtoull_or_die function is used to call the strtoull(3) system call. On failure an explanation will be printed to stderr, obtained from the explain_strtoull(3) function, and then the process terminates by calling exit(EXIT_FAILURE).
so basically: it tries, and if it flops, it prints you a lil explanation and then it dies. iconic. dramatic. periodt. π
the _on_error one β¨
The explain_strtoull_on_error function is used to call the strtoull(3) system call. On failure an explanation will be printed to stderr, obtained from the explain_strtoull(3) function, but still returns to the caller.
this one is the chill sibling β it tells you what went wrong, but it does NOT end the whole program. it just comes back and hands you the news. very mature of it honestly.
the args, bestie π
nptrβ Thenptr, exactly as to be passed to thestrtoull(3)system call. like, verbatim. no glow-up, no filter, straight through.endptrβ Theendptr, exactly as to be passed to thestrtoull(3)system call. same energy, untouched.baseβ Thebase, exactly as to be passed to thestrtoull(3)system call. yes, base 10, base 16, base whatever, exactly as-is. don't come for me.
fr fr, all three of these get passed through exactly as given. this function is not out here editing your arguments, it's not that kind of friend.
π RETURN VALUE π
The explain_strtoull_or_die function only returns on success, see strtoull(3) for more information. On failure, prints an explanation and exits, it does not return.
so like. if it comes back? slay, that's a win. if it doesn't come back? that's the whole point, babe. π
The explain_strtoull_on_error function always returns the value return by the wrapped strtoull(3) system call.
^^ (yes, "return" not "returned", that's how it's written, I'm keeping it, don't @ me) this one always comes back with whatever the wrapped strtoull(3) gave it. reliable queen. π
π EXAMPLE π
The explain_strtoull_or_die function is intended to be used in a fashion similar to the following example:
unsigned long long result = explain_strtoull_or_die(nptr, endptr, base);
look at her. one line. no error handling written by you. she handles it. she handles everything. π§
β SEE ALSO β
strtoull(3)β convert a string to an unsigned long integerexplain_strtoull(3)β explainstrtoull(3)errorsexit(2)β terminate the calling process
go read these too, they're the supporting cast and they ate. π₯
π COPYRIGHT π
libexplain version 1.4 Copyright (C) 2009 Peter Miller
okay and that's the whole page bestie π this was explain_strtoull_or_die(3), part of the Library Functions Manual, from libexplain version 1.4, Β© 2009 Peter Miller β big love to Peter for writing it, and big love to you for reading all the way down here. go convert some strings, but like, responsibly. mwah πβ¨π¦
π¦ where this page comes from
- debian bookworm: libexplain-dev 1.4.D001-12+b1 Β· LGPL-3.0-or-later
- debian trixie: libexplain-dev 1.4.D001-16 Β· LGPL-3.0-or-later
- ubuntu jammy: libexplain-dev 1.4.D001-12 Β· LGPL-3.0-or-later
- ubuntu noble: libexplain-dev 1.4.D001-13 Β· LGPL-3.0-or-later
- ubuntu resolute: libexplain-dev 1.4.D001-16 Β· LGPL-3.0-or-later
- Copyright (C) 2009, 2011 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms