ustrnicmp(3alleg4)

πŸ’– ustrnicmp β€” bestie edition πŸ’–

okay so this one is from the Allegro game programming library manual (section 3alleg4, we love a classic) and it's genuinely one of my faves because it's SO chill about case. like it just does not care. lowercase? uppercase? whatever, it's all the same to her. main character energy fr.


✨ NAME ✨

ustrnicmp β€” compares up to n letters of two strings, ignoring case. it's giving "i'm not gonna read your whole message, just the first bit, and also i'm not gonna care about caps." πŸ’…

part of the Allegro game programming library, obviously. πŸ‘‘


🌸 SYNOPSIS 🌸

#include <allegro.h>

int ustrnicmp(const char *s1, const char *s2, int n);

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically, ustrnicmp compares up to n characters of s1 and s2, and it ignores case the entire time. uppercase A? lowercase a? she literally cannot tell the difference and honestly? iconic.

here's the vibe, an actual example from the source:

if (ustrnicmp(prefix, long_string, ustrlen(prefix)) == 0) {
   /* long_string starts with prefix (ignoring case) */
}

see what she did there? she checked if long_string starts with prefix, no caps-shaming involved. that's the whole trick and it ate. πŸ”₯


⭐ RETURN VALUE ⭐

  • zero if the strings are equal
  • a positive number if s1 comes after s2 in the ASCII collating sequence
  • otherwise, a negative number

that's it, that's the tea. compare the sign, not the exact number, bestie. 😌


πŸ‘‘ SEE ALSO πŸ‘‘

go read those too, they're all in the same friend group. 🫢


and that's the page!! this was Allegro version 4.4.3, from the ustrnicmp(3alleg4) manual. go forth and compare strings without judging anyone's capitalization, mwah πŸ’–βœ¨πŸŽ€