ustrncmp(3alleg4)

✨ ustrncmp β€” bestie, let's compare some strings ✨

okay so this is ustrncmp from the Allegro game programming library πŸ’– and it does exactly what it says on the tin: it compares up to n letters of two strings. that's it. that's the whole vibe. πŸ¦‹


🌸 SYNOPSIS 🌸

#include <allegro.h>

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

πŸ’… DESCRIPTION πŸ’…

so like, ustrncmp compares up to n characters of s1 and s2. not the whole string, just the first n of them. iconic behavior honestly. πŸŽ€

here's the moment everyone's been waiting for, the example:

if (ustrncmp(prefix, long_string, ustrlen(prefix)) == 0) {
   /* long_string starts with prefix */
}

see what she's doing there? comparing exactly ustrlen(prefix) characters so she can check if long_string starts with prefix. queen behavior. no cap. πŸ‘‘


⭐ RETURN VALUE ⭐

  • returns zero if the substrings are equal 🫢
  • returns a positive number if s1 comes after s2 in the ASCII collating sequence
  • otherwise returns a negative number

that's the whole personality. positive, negative, or zero. main character energy fr fr. πŸ’€


🌈 SEE ALSO 🌈

go read those too bestie, they're all part of the same friend group 🧚✨


okay that's the whole page!! this was brought to you by Allegro, version 4.4.3, and the letter n πŸ’– stay slaying, and remember: ustrncmp only compares up to n characters, so don't come for her about the rest of the string. periodt. πŸ’…πŸŽ€πŸ¦‹πŸŒΈπŸ’œ