ustrncat(3)

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

πŸ’– ustrncat β€” the Allegro manual, but make it cute πŸ’–

okay bestie, welcome to the ustrncat(3) page from the Allegro manual, aka the Allegro game programming library ✨ this one's a string function and she's a little bit of a chaos goblin, so buckle up πŸŽ€


🌸 SYNOPSIS 🌸

#include <allegro.h>

char *ustrncat(char *dest, const char *src, int n);

πŸ’… DESCRIPTION πŸ’…

so basically ustrncat() is exactly like ustrcat() β€” same vibe, same energy β€” EXCEPT that it won't append more than n characters from src onto the end of dest. that's the whole ✨twist✨

now here's the part where the details matter, so listen up 🫢

  • if the terminating null character in src shows up before n characters have been written, that null character does get copied β€” but no other characters get written after it. she stops there, periodt.
  • if n characters get written before a terminating null is ever encountered, the function appends its own null character to dest β€” which means n+1 characters end up being written total. do the math, it's giving sneaky πŸ’€
⚠️ okay real talk: you should try to avoid this function, because it is very easy to overflow the destination buffer. like, dangerously easy. not cute. if you can, use ustrncat's better-behaved sibling ustrzncat instead πŸ‘‘ (yes, the extra z is doing a lot of heavy lifting here, iykyk)

πŸ¦‹ RETURN VALUE πŸ¦‹

the return value is just the value of dest. that's it, that's the whole tea πŸ“


🌈 SEE ALSO 🌈


and that's the page!! this came to you straight from the Allegro manual, version 4.4.3, on ustrncat(3) β€” stay safe out there and please don't overflow ur buffers, love u bestie πŸ’œπŸ§š

πŸ“¦ where this page comes from