|
NAMEstrdup , strndup —
save a copy of a string
LIBRARYStandard C Library (libc, -lc)SYNOPSIS#include <string.h>
char *
char *
DESCRIPTIONThestrdup () function allocates sufficient memory for a
copy of the string str, does the copy, and returns a
pointer to it. The memory is allocated with
malloc(3)
and should be released with
free(3)
when no longer needed.
The RETURN VALUESIf insufficient memory is available, NULL is returned and errno is set toENOMEM .
Otherwise, the strdup () family of functions return a
pointer to the copied string.
SEE ALSOfree(3), malloc(3), wcsdup(3)STANDARDSThestrdup () function is specified by
IEEE Std 1003.1-2001 (“POSIX.1”). The
strndup () function is specified by
IEEE Std 1003.1-2008 (“POSIX.1”).
HISTORYThestrdup () function first appeared in
4.3BSD-Reno. The strndup ()
function was added in FreeBSD 7.2.
Visit the GSP FreeBSD Man Page Interface. |