#include /* * Returns a newly allocated string with the same contents as . */ char * my_strdup(char *s) { char *end = s; char *result, *p; /* Find end of */ while (*end++) ; /* Copy (including '\0') to newly allocated memory */ p = result = malloc(end - s); while (s != end) *p++ = *s++; return result; }