fmt_plusminus(3)

πŸ“¦
version 0.34 Β· 2 versions
  • 0.34 Β· alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 0.30 Β· fedora 43, fedora 44, ubuntu jammy
, in alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– fmt_plusminus(3) πŸ’–

okay so bestie, we're in the Library Functions Manual and today's main character is fmt_plusminus β€” the tiniest, most unbothered little formatter in all of libowfat. she does ONE thing and she does it flawlessly. periodt. πŸ‘‘


✨ NAME ✨

fmt_plusminus β€” write '+' or '-'

like... that's it. that's the whole job. and honestly? iconic.


🌸 SYNTAX 🌸

#include <libowfat/fmt.h>

size_t fmt_plusminus(char *dest,signed int source);

no cap, that's the whole signature. two args, one size_t back. we love a low-maintenance queen. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the vibe check. fmt_plusminus looks at source and writes exactly one character into dest:

  • if source is negative β†’ it writes '-' πŸ’€
  • if source is positive β†’ it writes '+' ✨
  • if source is neither (aka zero, aka the neutral icon) β†’ it writes nothing at all πŸ™ˆ

then it returns the number of bytes written. that's the return value, bestie, don't sleep on it.

heads up fr fr: fmt_plusminus does not append \0. no null terminator, no little goodbye note, nothing. if you were expecting a cute lil string ending you're gonna have to handle that yourself. πŸ’…

and here's the fun part β€” if dest equals FMT_LEN (i.e. is zero), fmt_plusminus returns the number of bytes it would have written. it's giving "window shopping" energy. no actual writing happens, she's just telling you how much space she'd need. 🌈


⭐ SEE ALSO ⭐

go read those too, iykyk, they're the friend group. πŸŽ€


and that's the whole page, babe!! this was fmt_plusminus(3) from the Library Functions Manual β€” mwah, go format something cute, ily, bye!! πŸ’–πŸ¦‹πŸŒΈ