strdup(3) Library Functions Manual strdup(3) strdup, strndup - (libc -lc) #include char *strdup(const char *s); char *strndup(size_t n; const char s[n], size_t n); glibc ( feature_test_macros(7)): strdup(): _XOPEN_SOURCE >= 500 || /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200809L || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE strndup(): glibc 2.10: _POSIX_C_SOURCE >= 200809L glibc 2.10: _GNU_SOURCE strdup() s. malloc(3) free(3). strndup() n . s n n ('\0'). strdup() . NULL errno . ENOMEM . attributes(7). +------------+------------------------------------+--------------------+ || | | +------------+------------------------------------+--------------------+ |strdup(), | | MT-Safe | |strndup() | | | +------------+------------------------------------+--------------------+ POSIX.1-2008. strdup() SVr4, 4.3BSD-Reno, POSIX.1-2001. strndup() POSIX.1-2008. alloca(3), calloc(3), free(3), malloc(3), realloc(3), string(3), strdupa(3), strndupa(3), wcsdup(3) 3 . . : . 6.18 25 2026 strdup(3)