1 2 3 4 5 6 7 8 9 10 11 12 13 14
/* Name: cnvstr() * Desc: Converts a pointer, and length pair into a null-terminated string. * Args: * s: Pointer to convert. * len: Length to convert. * Return value: Returns a null-terminated string. */ char *cnvstr(char *s, int len) { char *p = malloc(len+1); memcpy(p, s, len); p[len] = '\0'; return p; }