uinsert(3)

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

✨ uinsert(3) ✨

okay bestie, welcome to the Allegro manual πŸ’– this one's a lil function called uinsert, and it's literally the "scooch over, i'm getting in" of string manipulation. no cap.


🌸 NAME 🌸

uinsert β€” inserts a character in a string. part of the Allegro game programming library, and yes she's iconic πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <allegro.h>

int uinsert(char *s, int index, int c);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜• β€” uinsert takes that character c and slides it into the string s at the spot you picked, index. and the way it does that? it slides the rest of the data along to make room 🫢 like when your bestie squeezes onto the couch and everyone else has to shuffle down. no one gets deleted, everyone just moves.

and if index is negative? don't worry, she's flexible β€” a negative index counts backward from the end of the string πŸ”₯ so you can count from the back like it's a line at a concert.

here's the example straight from the source, keep it exact bestie:

uinsert(text_string, 0, prefix_letter);

that's her! inserting prefix_letter at position 0, aka the very front πŸ‘‘


πŸ‘‘ RETURN VALUE πŸ‘‘

she gives you back the number of bytes by which the trailing part of the string was moved. so like, receipts. how far did everybody have to scooch? now you know ✨


πŸ’œ SEE ALSO πŸ’œ

go read those too, they're all in the same friend group fr fr 🧚


⚠️ heads up bestie: make sure the string you're passing in actually has room for that extra character, because sliding data into a buffer that can't hold it is not the vibe. periodt.

Allegro, version 4.4.3 🌈 β€” mwah, that's the whole page, thanks for reading my little manual moment, ily, bye πŸŽ€πŸ’–βœ¨

πŸ“¦ where this page comes from