ustrzcat(3alleg4)

πŸ’– ustrzcat β€” it's a 3alleg4 girlie, Allegro manual energy πŸ’–

okay so bestie, we're in the Allegro game programming library and this one is ustrzcat(3alleg4) β€” the string-gluing queen who also knows her own size. no cap.


✨ SYNOPSIS ✨

#include <allegro.h>

char *ustrzcat(char *dest, int size, const char *src);

🌸 DESCRIPTION 🌸

so what she does is: she concatenates src onto the end of dest. but here's the twist that makes her iconic β€” the length of dest in bytes is specified by size, and she guarantees it's null-terminated, even when src is bigger than size. like, she ate and left no crumbs. πŸ”₯

⚠️ okay but listen, this is the part where you gotta pay attention: even for empty strings, your destination string needs at least enough bytes to hold the terminating null character of the string, and your size parameter has to reflect that. like fr fr.

and if you don't do that? the vibe check fails HARD:

  • the debug version of Allegro will abort at an assertion πŸ’€
  • the release version of Allegro will overrun the destination buffer 😭

so like, please give her room to breathe. she's not asking for much, she's asking for a null terminator's worth of space. periodt.


πŸŽ€ RETURN VALUE πŸŽ€

she hands you back the value of dest. that's it, that's the whole return. giving you back exactly what you gave her, plus a little extra string energy. πŸ’…


πŸ¦‹ SEE ALSO πŸ¦‹

go read those too bestie, iykyk 🫢


Allegro version 4.4.3 β€” mwah, that's the version and the vibe, from your fave ustrzcat(3alleg4) page. stay safe out there and always count your bytes. πŸ’–βœ¨πŸŽ€πŸ¦‹