char *strdup(const char *s1);

strdup duplicates the string pointed to by s1 by using malloc to allocate memory for a copy of s and then copying s, including the terminating null, to that memory strdup returns a pointer to the new string or a null pointer if the new string cannot be created. The returned pointer can be passed to free.


strdup conforms to POSIX.1-2008 and SC22 TR 24731-2.