scan_ulong(3)
π scan_ulong(3) π
okay bestie, welcome to scan_ulong(3) from the Library Functions Manual β she's a lil libowfat legend and she's here to turn your text into a number, no drama, no detours. let's get into it π«Ά
β¨ NAME β¨
scan_ulong β parse an unsigned long integer in decimal ASCII representation
πΈ SYNTAX πΈ
#include <libowfat/scan.h>
size_t scan_ulong(const char *src,unsigned long *dest);
π DESCRIPTION π
so scan_ulong does the thing: it parses an unsigned long integer in decimal ASCII representation out of src, and writes the result straight into dest. and then β the part everyone forgets β it returns the number of bytes it read from src. periodt.
now, she is picky and we love that for her. a leading + or - or space (or literally anything outside of 0-9) is not accepted. and no, she does not do the libc conventions where "023" means octal or "0x23" means hexadecimal β those are not supported. nope. not the vibe. π
she also knows when to stop: scan_ulong will abort the scan if the next character is not a digit, or if it is a digit but adding it to the number would lead to an integer overflow. she's not about to let you overflow, bestie, that's not happening on her watch. π
π RETURN VALUE π
scan_ulong returns the number of characters successfully scanned and processed from src. that's it, that's the tea β how far she got, in bytes. β¨
π¦ EXAMPLES π¦
okay these are so satisfying, watch:
scan_ulong("23",&i) -> i=23, return 2
scan_ulong("+23",&i) -> return 0
scan_ulong("-23",&i) -> return 0
scan_ulong(" 23",&i) -> return 0
scan_ulong("23,42",&i) -> i=23, return 2
scan_ulong("023",&i) -> i=23, return 3
scan_ulong("0x23",&i) -> i=0, return 1
scan_ulong("4294967296",&i") -> i=429496729, return 9 // 32-bit system
see how "023" gives you i=23 with return 3 β she read all three digits, she just doesn't do octal. and "0x23"? she grabs the 0, hits the x, and bails β i=0, return 1. iconic behaviour honestly. π
π SEE ALSO π
and that's the whole page, bestie!! this was scan_ulong(3), living in section 3 of the Library Functions Manual, and yeah β same name up top, same name down at the bottom, she's consistent like that. π go forth and parse responsibly, mwah π§π
π¦ where this page comes from
- alpine 3.24: libowfat-doc 0.34-r0 Β· GPL-2.0-only
- debian bookworm: libowfat-dev 0.32-4 Β· GPL-2.0-only
- debian trixie: libowfat-dev 0.32-5 Β· GPL-2.0-only
- nixos 26.05: libowfat 0.34
- nixpkgs unstable: libowfat 0.34
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- ubuntu noble: libowfat-dev 0.32-4.1build1 Β· GPL-2.0-only
- ubuntu questing: libowfat-dev 0.32-5
- ubuntu resolute: libowfat-dev 0.34-2 Β· GPL-2.0-only
- ubuntu stonking: libowfat-dev 0.34-2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms