strdup
Creates a duplicate of a string
#include <string.h>
char *strdup (
const char *src);
The strdup function returns the pointer to the new copy of the string if successful; otherwise, it returns NULL.
The strdup function creates a duplicate of the string pointed to by src and returns a pointer to the new copy. The memory for the new string is obtained by using the malloc function and can be freed using the free function.
#include <string.h>
#include <stdio.h>
main ()
{
char *new;
new = strdup ("Make a copy");
printf (new);
free (new);
}