#define _USE_XOPEN #include #include char * strdup(const char *s) { int len = strlen(s); char *d; d = malloc(len); if (d == NULL) return NULL; strcpy(d, s); return d; }