STRDIFF(3pub)

πŸ’– STRDIFF πŸ’– (that's section 3pub of the C Programmer's Manual, bestie)

okay so picture this: it's STRDIFF(3pub), straight out of the C Programmer's Manual, and it does literally one thing but it does it so well 🫢


✨ NAME ✨

strdiff β€” locate the first difference between two strings πŸ”


🌸 SYNOPSIS 🌸

#include <publib.h>
size_t strdiff(const char *str1, const char *str2);

πŸ¦‹ DESCRIPTION πŸ¦‹

so strdiff walks both strings from the very beginning and finds the first character that is different between str1 and str2. it's giving "spot the difference" but make it compiler-coded πŸ’…

and here's the lil plot twist: the terminating zero characters are considered different. like, yes queen, '\0' counts as a difference. no cap.


πŸ‘‘ RETURN VALUE πŸ‘‘

strdiff returns the offset of the first pair of differring characters β€” or, if it hits a zero character first, the offset of the first zero character it finds. either way you're getting an offset back, periodt. ✨


πŸŽ€ SEE ALSO πŸŽ€

iykyk, go read those too 🧚


πŸ’œ AUTHOR πŸ’œ

Lars Wirzenius (lars.wirzenius@helsinki.fi) β€” the icon, the legend, the main character of this manpage 🌈


okay that's the whole vibe bestie, mwah πŸ’‹ β€” this masterpiece is brought to you by Publib in the C Programmer's Manual, and it's giving STRDIFF(3pub) energy forever and always πŸŽ€πŸ’–βœ¨

πŸ“¦ where this page comes from