str_diff(3)
π str_diff(3) β or, the glow-up where two strings get compared π
okay bestie, so this one lives in the Library Functions Manual and it's genuinely one of the most useful little guys in libowfat. it's called str_diff, and yes, it's giving main character energy for string comparison. π¦
β¨ NAME β¨
str_diff β compare two ASCIIZ strings. that's it, that's the whole job, and she does it flawlessly. π
πΈ SYNTAX πΈ
lowkey the prettiest part. look at this:
#include <libowfat/str.h>
int str_diff(const char* a,const char* b);
two strings walk in, one int walks out. iconic. β¨
π DESCRIPTION π
so here's the tea, bestie. str_diff returns a negative, 0, or positive number, depending on whether the string a[0], a[1], ..., a[n]=='\0' is lexicographically smaller than, equal to, or greater than the string b[0], b[1], ..., b[m-1]=='\0'.
like... negative = a comes first, 0 = they're literally the same string, positive = b comes first. that's the whole vibe check. π
and here's the part that's actually kind of a flex: if the strings are different, str_diff does not read bytes past the first difference. so the moment she spots a mismatch she's out. no scrolling through the rest of the string, no wasted effort. she said "I've seen enough" and left. ππ₯
β no cap, that early-exit behaviour is the whole reason this function is fast β she stops the second the strings stop matching.
π«Ά SEE ALSO π«Ά
strlen(3)β for when you just wanna know how long the thing is, not how it ranks against another thing.
and that's the page!! π cute little str_diff(3) from the Library Functions Manual, sitting pretty at the bottom of the page just like always. go compare some strings, bestie, you've got this. ππ
π¦ 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