1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14.

Thursday, April 9, 2009

Write a C program to implement your own strdup() function.

Here is a C program to implement the strdup() function.


char *mystrdup(char *s)
{
char *result = (char*)malloc(strlen(s) + 1);
if (result == (char*)0){return (char*)0;}
strcpy(result, s);
return result;
}

 
# #