Home >>C String functions >C strdup() function
C strdup() function are used to duplicate the given String.
Syntax:Strdup(str)
Note:- Here str is given string.
It takes string and character as parameter.
It returns duplicate string.
Example-1
#include <stdio.h>
#include <string.h>
int main()
{
char *p1 = "sama";
char *p2;
p2 = strdup(p1);
printf("Duplicate string is : %s", p2);
return 0;
}