ustrchr(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

πŸ’– ustrchr β€” the Allegro manual, but make it a group chat πŸ’–

okay bestie so you're in the Allegro game programming library, section 3 of the manual, and the star of today's episode is ustrchr β€” she finds the first occurrence of a character in a string. that's it. that's the girl. she's simple, she's reliable, she's giving ✨search-and-you-shall-find✨ energy.


✨ NAME ✨

ustrchr β€” Finds the first occurrence of a character in a string. Allegro game programming library. πŸŽ€


🌸 SYNOPSIS 🌸

#include <allegro.h>

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

like. look at her. two args. zero drama. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

Finds the first occurrence of the character c in the string s. that's the whole vibe β€” she walks down the string and the SECOND she spots your lil character she goes "found it, periodt" and points right at it. 🫢

Example, because we love a demo:

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

in this scenario p is gonna point at the very first ',' in "one,two,three,four" β€” the one right after one. she does NOT keep looking for more commas. first one wins. no cap. πŸ”₯


😭 RETURN VALUE 😭

Returns a pointer to the first occurrence of c in s, or NULL if no match was found. so if your character is literally nowhere in the string, you get NULL back and you have to deal with that emotionally. πŸ’€

lowkey important caveat bestie: Note that if c is NULL, this will return a pointer to the end of the string. not the start, not a crash, the end. she's quirky like that. know it before it jumpscares you. πŸ™ˆ

πŸ‘‘ SEE ALSO πŸ‘‘

the whole friend group, go say hi:


okay that's the page!! Allegro, version 4.4.3, and this whole thing lives at ustrchr(3) in the manual. mwah, go point at some characters, you're doing amazing sweetie πŸ’–πŸ¦‹βœ¨πŸŽ€πŸŒΈ

πŸ“¦ where this page comes from