STRNINS(3pub)

πŸ’– STRNINS(3pub) πŸ’–

okay bestie, welcome to the Publib corner of the C Programmer's Manual 🌸 this one's a lil function called strnins, and she's here to shove the front of one string onto the front of another. no cap, that's the whole job. 🫢


✨ NAME ✨

strnins β€” insert prefix of a string at the beginning of another string πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <publib.h>
char *strnins(char *tgt, const char *src, size_t n);

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea, bestie: strnins inserts up to n characters from the beginning of the src string at the beginning of the tgt string. 🌈

(and yes, the page literally says strins right there in that sentence β€” it's giving sibling energy, iykyk, we move πŸ’€)

Two things you absolutely cannot skip, fr fr:

  • The strings must not overlap. Not a vibe check you wanna fail. πŸ™ˆ
  • The target string must contain enough memory to hold both strings. Like, the whole both. πŸ‘‘

πŸ’œ RETURN VALUE πŸ’œ

strnins returns its first argument. that's it, that's the whole gift. it just hands you back your tgt. iconic behaviour honestly 🎁✨


πŸ“ EXAMPLE πŸ“

Not me gatekeeping... but the example lives elsewhere: see the manual page for strdel(3) for an example. go go go πŸƒβ€β™€οΈπŸ’¨


🌟 SEE ALSO 🌟


πŸ‘‘ AUTHOR πŸ‘‘

Lars Wirzenius (lars.wirzenius@helsinki.fi) β€” the main character who wrote this 🫢


⚠️ real talk, no cap: overlap = undefined chaos and not enough memory in tgt = also chaos. this function trusts you completely, so please be trustworthy. πŸ’€

k that's the whole page babes πŸ’– it's from Publib, it's the C Programmer's Manual, and it's literally just STRNINS(3pub). mwah, go write some safe string code for me 🌸🧚✨

πŸ“¦ where this page comes from