wcpncpy(3)
π wcpncpy(3) π
okay bestie, so this is wcpncpy(3) from the Library Functions Manual β yes, the Library Functions Manual, the one we all know and love π. sit down, grab a boba, and let me tell you about the wide-character girlboss who copies strings and then points you to the end of her work. no cap.
β¨ NAME β¨
wcpncpy β copy a fixed-size string of wide characters, returning a pointer to its end
like, she copies a fixed-size string of wide characters AND hands you back a pointer to the end. multitasking queen π
π LIBRARY π
Standard C library (libc, -lc)
the classic. the original. the one that raised us π«Ά
π SYNOPSIS π
#include <wchar.h>
wchar_t *wcpncpy(size_t n;
wchar_t dest[restrict n],
const wchar_t *restrict src,
size_t n);
π§ Feature Test Macro Requirements for glibc π§
(peep feature_test_macros(7) if u wanna know more, bestie)
wcpncpy():
Since glibc 2.10:
_POSIX_C_SOURCE >= 200809L
Before glibc 2.10:
_GNU_SOURCE
so if ur on glibc 2.10 or later u need _POSIX_C_SOURCE >= 200809L, and if ur on something older than glibc 2.10 u need _GNU_SOURCE. the way glibc keeps receipts of its own history... iconic honestly π
π DESCRIPTION π
so wcpncpy() is literally the wide-character equivalent of the stpncpy(3) function. that's the whole vibe. she's the wide-char sister π¦
she copies at most n wide characters from the wide-character string pointed to by src β including the terminating null wide (L'\0') β over to the array pointed to by dest. and exactly n wide characters get written at dest. exactly. she does not do half measures, bestie β¨
here's the tea tho:
- if the length
wcslen(src)is smaller than n, the remaining wide characters in the array pointed to bydestare filled withL'\0'characters. padding queen π - if the length
wcslen(src)is greater than or equal to n, the string pointed to bydestwill not beL'\0'terminated. π no null terminator. she just... stops. it's giving cliffhanger.
β οΈ okay this is important β the strings may not overlap. do not make them overlap. that's cursed behaviour territory, and not the fun kind of cursed π
β οΈ and also β the programmer must ensure that there is room for at least n wide characters at dest. that's on YOU, bestie. she is not checking. she is trusting u. do not betray her trust π
π₯ RETURN VALUE π₯
wcpncpy() returns a pointer to one past the last non-null wide character written β that is:
dest + wcsnlen(src, n)
so she walks u to the finish line. main character exit πΆβοΈβ¨
π ATTRIBUTES π
for an explanation of the terms used in this section, peep attributes(7). it's required reading, iykyk.
- Interface:
wcpncpy() - Attribute: Thread safety
- Value:
MT-Safe
translation: MT-Safe means she's thread-safe, so multiple threads can hang out with her at the same time and nobody's gonna start drama π₯
β STANDARDS β
POSIX.1-2008.
certified. official. no notes. periodt π
πΈ SEE ALSO πΈ
stpncpy(3)β the narrow-char siblingwcsncpy(3)β the other wide-char cousin
go read those too, bestie, the family is adorable π«Ά
and that's the whole page!! π¦π this little baby lives in Linux man-pages 6.20, dated 2026-02-08. love that for her. go forth and copy wide characters responsibly, and remember: exactly n or nothing at all β¨ππ
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms