ustrncat(3alleg4)

✨ NAME ✨

ustrncat β€” concatenates a string to another one, but like, with a size limit bestie πŸ’… and it's part of the Allegro game programming library πŸŽ€ (yes this is ustrncat(3alleg4), we're in the Allegro manual, iykyk).


🌸 SYNOPSIS 🌸

#include <allegro.h>

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

πŸ’– DESCRIPTION πŸ’–

Okay so picture ustrcat() 🫢 β€” this is literally that, except no more than n characters from src get appended to the end of dest. That's the whole vibe. You're capping how much gets glued on.

Now here's the tea on how it actually behaves, and you need to know this fr fr:

  • If the terminating null character in src gets reached before n characters have been written, then the null character is copied, but no other characters are written after it. The string just ends there, periodt.
  • If n characters get written before a terminating null is encountered, the function appends its own null character to dest, so that n+1 characters are written. So you get n of the content plus its own little null bow on top πŸŽ€.
⚠️ bestie. listen. You should try to avoid this function because it is very easy to overflow the destination buffer. Like, dangerously easy. Not cute. Use ustrzncat instead β€” that's the one you want. πŸ™ˆ

⭐ RETURN VALUE ⭐

The return value is just the value of dest. That's it. It hands you back your own dest pointer, main character behavior honestly πŸ‘‘.


πŸ¦‹ SEE ALSO πŸ¦‹


k bye bestie, go read those other ones too, they're all linked up like a little friend group 🌈

mwah πŸ’– this page came from the Allegro manual, version 4.4.3, dated ustrncat(3alleg4) β€” slay, no cap, go write some safe string code ✨πŸ’