stpcpy(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… stpcpy

okay so bestie, this is stpcpy from the kernel API manual, and she is that girl β€” but like, the risky kind of that girl. buckle up πŸŽ€


✨ NAME ✨

stpcpy β€” copies a string from src to dest, and returns a pointer to the new end of dest, including src's %NUL-terminator. also like… may overrun dest. πŸ™ˆ (yes that's in the official description, no I'm not being dramatic)


🌸 SYNOPSIS 🌸

char * stpcpy (char *__restrict__ dest , const char *__restrict__ src );

that's it. that's the whole signature, she's lowkey serving minimalism πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • dest β€” pointer to the end of the string being copied into. she must be large enough to receive the whole copy, no exceptions, no vibes-based sizing 😭
  • src β€” pointer to the beginning of the string being copied from. she must not overlap dest, fr fr, don't even try it

πŸ‘‘ DESCRIPTION πŸ‘‘

so here's the tea: stpcpy differs from strcpy in one key way β€” the return value is a pointer to the new NUL-terminating character in dest. (for strcpy, the return value is a pointer to the start of dest. yeah. different girl, different energy.)

this interface is considered unsafe because it doesn't perform bounds checking of the inputs. so like, no safety net, no vibe check on your buffer size, nothing. as such it's not recommended for usage β€” like genuinely, don't 🫢

instead, its definition is provided in case the compiler lowers other libcalls to stpcpy. so she's basically here for the compiler's convenience, not yours. icon behavior honestly ✨

⚠️ real talk: no bounds checking means if your buffer's too small, dest gets overrun. that's not a bug note, that's just the whole personality of this function. respect it or get got πŸ’€

🌈 SEE ALSO 🌈

kernel file ./lib/string.c β€” and literally all her friends:

strncasecmp(9), strcmp(9), strncmp(9), strchr(9), strchrnul(9), strnchrnul(9), strrchr(9), strnchr(9), strspn(9), strcspn(9), strpbrk(9), strsep(9), memset(9), memset16(9), memset32(9), memset64(9), memcpy(9), memmove(9), memcmp(9), bcmp(9), memscan(9), strstr(9), strnstr(9), memchr(9), memchr_inv(9)

like… the whole group chat showed up πŸ«ΆπŸ’–


aaaand that's the page!! πŸŽ€ this one came out of ./lib, dated October 2026 β€” stay safe out there with those buffers bestie, mwah πŸ’œβœ¨

πŸ“¦ where this page comes from