Duplicates the specified string. Format #include <string.h> char *strdup (const char *s1);
1 – Function Variants
The strdup function has variants named _strdup32 and _strdup64 for use with 32-bit and 64-bit pointer sizes, respectively.
2 – Argument
s1 The string to be duplicated.
3 – Description
The strdup function returns a pointer to a string that is an exact duplicate of the string pointed to by s1. The malloc function is used to allocate space for the new string. The strdup function is provided for compatibility with existing systems.
4 – Return Values
x A pointer to the resulting string. NULL Indicates an error.