#include #define MAXLEN 20 void strcat2(char *ps, char *pt); int main() { char t[MAXLEN]; char s[MAXLEN]; int i = 0, c; while ((c = getchar()) != EOF) { t[i++] = c; /* i is now incremented, so t[i] points to the wrong place. */ if (t[i-1] == '\n') { strcat2(s, t); printf("%s", s); i = 0; } } return 0; } int s_index = 0; void strcat2(char *ps, char *pt) { ps += s_index; while (s_index < MAXLEN && (*ps++ = *pt++) != '\n') s_index++; /* The '\0' character (0), signifies the end of a string. */ *ps = '\0'; }