ustrchr(3alleg4)

πŸ’– NAME πŸ’–

okay bestie, so ustrchr is literally the girl who finds the first occurrence of a character in a string πŸŽ€ and she's part of the Allegro game programming library ✨ slay


✨ SYNOPSIS ✨

#include <allegro.h>

char *ustrchr(const char *s, int c);

like, that's the whole vibe check right there πŸ’…


🌸 DESCRIPTION 🌸

so what she does is: she finds the first occurrence of the character c in the string s. that's it, that's the job, and she ate πŸ”₯

here's the moment, fr fr:

char *p = ustrchr("one,two,three,four", ',');

like she's gonna hunt down that very first comma and point at it. iconic behavior honestly 🌈


πŸ¦‹ RETURN VALUE πŸ¦‹

she hands you back a pointer to the first occurrence of c in s 🫢 and if there's genuinely no match anywhere? you get NULL. no match, no pointer, we move on πŸ’€

ngl there's a lil plot twist here: if c is NULL, she returns a pointer to the end of the string. not the start, not somewhere in the middle β€” the end. the way that's lowkey cursed but also so valid 😭

πŸ‘‘ SEE ALSO πŸ‘‘

like the whole friend group, go say hi πŸ’œ


kisses, this was brought to you by Allegro, version 4.4.3, repping the ustrchr(3alleg4) page β€” stay hydrated and always check your return values πŸ’–βœ¨πŸŽ€