1 #include <string.h> 2 #include <ctype.h> 3 #include <stdlib.h> 4 5 char* strdup(char * p)6 strdup(char *p) 7 { 8 int n; 9 char *np; 10 11 n = strlen(p)+1; 12 np = malloc(n); 13 if(np) 14 memmove(np, p, n); 15 return np; 16 } 17