explain_strtold_or_die(3)

πŸ“¦
version 1.4.D001 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute

πŸ‘‘ explain_strtold_or_die(3) πŸ‘‘

okay bestie, gather round, because this one is a Library Functions Manual page and it is genuinely so useful it's not even funny. it's called explain_strtold_or_die, and it lives in the libexplain cinematic universe. πŸ’–


✨ NAME ✨

explain_strtold_or_die β€” convert string to number and report errors


πŸŽ€ SYNOPSIS πŸŽ€

#include <libexplain/strtold.h>
long double explain_strtold_or_die(const char *nptr, char **endptr);
long double explain_strtold_on_error(const char *nptr, char **endptr))
yes bb, that is two closing parens on the second line. that's literally what the page says, so that's literally what we're keeping. iykyk. πŸ’…

🌸 DESCRIPTION 🌸

so here's the vibe. there are two little functions here and they're basically sisters, one is just a lil more dramatic than the other.

  • explain_strtold_or_die β€” this one is used to call the strtold(3) system call. and if it fails? an explanation gets printed to stderr, obtained from the explain_strtold(3) function, and then the process terminates by calling exit(EXIT_FAILURE). it's giving main character energy, honestly. it does not come back. πŸ’€
  • explain_strtold_on_error β€” same deal, it's used to call the strtold(3) system call, and on failure an explanation is printed to stderr, obtained from the explain_strtold(3) function… but this one still returns to the caller. chillest of the two. no exit, no drama. 🫢

and the arguments, bestie, they are literally just passed straight through:

  • nptr β€” the nptr, exactly as to be passed to the strtold(3) system call.
  • endptr β€” the endptr, exactly as to be passed to the strtold(3) system call.

like. no notes. it hands them over untouched. periodt. ✨


🌈 RETURN VALUE 🌈

  • explain_strtold_or_die only returns on success. want more info on that? see strtold(3). on failure, it prints an explanation and exits β€” it does not return. nope. not happening. not ever. πŸ’…
  • explain_strtold_on_error always returns the value return by the wrapped strtold(3) system call. (yes, "return", not "returned" β€” we're keeping it exactly as written, don't look at me πŸ™ˆ)

πŸ¦‹ EXAMPLE πŸ¦‹

the explain_strtold_or_die function is intended to be used in a fashion similar to the following example:

long double result = explain_strtold_or_die(nptr, endptr);

one line. one call. iconic behaviour. ⭐


πŸ’œ SEE ALSO πŸ’œ


libexplain version 1.4 Copyright (C) 2009 Peter Miller


and that's the whole page, bestie!! 🧚✨ this was explain_strtold_or_die(3) from the Library Functions Manual, brought to you by libexplain version 1.4, with Copyright (C) 2009 Peter Miller holding it down at the bottom. go forth and convert your strings, and remember: one of these functions will absolutely exit on you and it is not sorry about it. πŸ’–πŸ‘‘πŸ¦‹

πŸ“¦ where this page comes from