fmt_ulong0(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_ulong0(3) ✨ β€” the libowfat glow-up πŸ’…

okay bestie, gather round, because today we're talking about fmt_ulong0, a little function from the Library Functions Manual corner of libowfat and honestly? she's giving zero-padded unsigned long realness and I'm obsessed πŸŽ€


🌸 NAME 🌸

fmt_ulong0 β€” write a zero-padded ASCII representation of an unsigned long integer πŸ’–


πŸ¦‹ SYNTAX πŸ¦‹

like, here's how you pull up on her:

#include <libowfat/fmt.h>

size_t fmt_ulong0(char *dest, unsigned long source,
                        size_t n);

✨ DESCRIPTION ✨

so fmt_ulong0 writes an ASCII representation (that's '0' through '9', base 10, no cap) of source into dest, and then it hands you back the number of bytes it actually wrote. simple. iconic. πŸ’…

the output gets padded with '0'-bytes until it covers at least n bytes. and the way that she will not truncate if it doesn't fit?? she just lets it overflow, respectfully. no shrinking, no cutting corners, periodt.

🫢 also she does not append \0. so don't be out here expecting a null terminator, bestie, that's not her job.

and if dest equals FMT_LEN (aka it's zero), then fmt_ulong0 just returns the number of bytes it would have written. it's like a lil preview, a vibe check before the main character moment 🌈

for convenience β€” because libowfat loves us β€” fmt.h defines the integer FMT_ULONG to be big enough to hold every possible fmt_ulong output plus \0. so like, sized correctly, always 🧚


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole thing, bestie!! slay πŸ’œ this lil baddie is from the Library Functions Manual and the footer's giving fmt_ulong0(3) energy β€” same name, same date, same everything, fr fr. go forth and zero-pad responsibly βœ¨πŸŽ€πŸŒΈ