strdup3
Save a copy of a string
Usage
#include <string.h>
char *
strdup(const char *s1);
char *
strndup(const char *s1, size_t n);
Library
Standard C Library (libc, -lc)
Overview
The strdup() function allocates sufficient memory for a copy of the string s1, does the copy, and returns a pointer to it. The pointer may subsequently be used as an argument to the function free(3).
If insufficient memory is available, NULL is returned and errno is set to ENOMEM.
The strndup() function copies at most n characters from the string s1 always NUL terminating the copied string.
Releases
163 releases since Mac OS X 10.0; the text changed 4 times.