/* p12b.c */ #include #include /* The mission of this function is to catenate */ /* the string pointed to by p2 to the end of */ /* the string pointed to by p1 */ char *zstrcat( char *p1, char *p2) { char *r = p1; /* Start by advancing dest to the end */ /* of the string pointed to by p1 */ while (*p1++); p1--; /* Now tack on the string pointed to by p2 */ while (*p1++ = *p2++); return(r); } main() { char *s1; char *s2; char *result; s1 = (char *)malloc(40); s2 = (char *)malloc(40); result = (char *)malloc(81); *result = 0; fgets(s1, 40, stdin); fgets(s2, 40, stdin); zstrcat(result, s1); zstrcat(result, " "); zstrcat(result, s2); fputs(result, stdout); }