al_ustr_find_str(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ al_ustr_find_str ✨

okay bestie, so this is a page from the Allegro 5 API β€” specifically the 3alleg5 manual section πŸ’– β€” and today's main character is al_ustr_find_str, the little function that goes hunting for one string inside another. it's giving detective energy πŸ”βœ¨


🌸 SYNOPSIS 🌸

#include <allegro5/allegro.h>

int al_ustr_find_str(const ALLEGRO_USTR *haystack, int start_pos,
   const ALLEGRO_USTR *needle)

like. look at that signature. three args, one int back. no cap, it's that simple πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: you've got your haystack (the big string you're searching in) and your needle (the little string you're looking for) πŸͺ‘ and this function finds the first occurrence of needle inside haystack. iconic behaviour, honestly.

but wait β€” there's a starting point πŸ‘€ the search kicks off from start_pos, which is a byte offset, and that offset is inclusive. so yes, start_pos itself is very much invited to the party πŸŽ‰

if it finds the thing? you get the byte offset of the occurrence back 🫢 if it doesn't find the thing? you get -1. that's it. that's the whole deal. not me getting emotional over a return value 😭

heads up bestie: start_pos is a byte offset, not a character index. keep that in mind or the vibe check will fail πŸ’€

🌈 SEE ALSO 🌈


and that's the whole page, periodt πŸ’… this was al_ustr_find_str(3alleg5) straight out of the Allegro reference manual β€” go forth, find your strings, slay πŸŒŸπŸ’–πŸŽ€

πŸ“¦ where this page comes from