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;
}
Thursday, April 9, 2009
Write a C program to implement your own strdup() function.
Posted by Raghu Kumar on 6:56 AM
RSS Feed
Twitter
Orkut