al_ustr_assign_substr(3)

πŸ“¦
version 5.2.11.3 Β· 3 versions
, in arch rolling

πŸ’– al_ustr_assign_substr(3) πŸ’–

okay bestie, welcome to the Allegro 5 API β€” this one lives in the Library Functions Manual, and it's genuinely one of the cutest little string functions out there, no cap ✨


🌸 NAME 🌸

al_ustr_assign_substr β€” Allegro 5 API 🫢


✨ SYNOPSIS ✨

#include <allegro5/allegro.h>

bool al_ustr_assign_substr(ALLEGRO_USTR *us1, const ALLEGRO_USTR *us2,
   int start_pos, int end_pos)

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


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea πŸ“: this function overwrites the string us1 with the contents of us2 β€” but only the slice of us2 in the byte interval [start_pos, end_pos). it's giving "cut and paste but make it bytes" πŸ’…

note the interval, bestie: start_pos is included, end_pos is not β€” classic half-open situation, iykyk πŸ”₯

and the end points? they get clamped to the bounds of us2 β€” so if you go a little feral with your numbers, it just politely clamps instead of exploding πŸ’€ (still, maybe don't test fate)

usually you'll first have to use al_ustr_offset(3) to find the byte offsets β€” that's your little map to the territory, fr fr 🧚

returns true on success, false on error 😭


πŸŽ€ SEE ALSO πŸŽ€


lowkey the whole point: slice + overwrite + clamp. periodt πŸ’œ

okay that's the whole page bestie, you ate that reading session πŸ‘‘ this was the Allegro reference manual, al_ustr_assign_substr(3), mwah πŸ’‹

πŸ“¦ where this page comes from
  • arch rolling: allegro 5.2.11.3-2 Β· Zlib AND BSD-3-Clause AND OFL-1.1 AND LicenseRef-Custom
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms