#include #include //custom getline method, it sucks but oh well, live with it char* getline(){ int ch, i = 0; char *toWorkWith, *temp; toWorkWith = (char*) malloc(sizeof(char) + 1); while ((ch = getchar()) && ch != '\n' && ch != '\0'){ toWorkWith[i] = ch; i++; temp = (char*) realloc(toWorkWith, ((i + 3) * sizeof(char))); if (temp != NULL){ toWorkWith = temp; } else{ fprintf(stderr, "out of memory!"); } } toWorkWith[i] = '\0'; return toWorkWith; } int main(int argc, char* argv[]){ int i, j, k, count; char *flags, temp = 0; char **words; count = atoi(getline()); words = malloc(count * sizeof(char)); flags = malloc(count * sizeof(char)); for (i = 0; i < count; i++){ printf("Loop %d of %d\n", i, count); words[i] = getline(); flags[i] = 0; } for (i = 0; i < 256; i++){ for (j = 0; j < count; j++){ if (words[j][i] == '\0'){ flags[j] = 1; } if (flags[j]){ printf(" "); } else{ printf("%c", words[j][i]); } } printf("\n"); for (k = 0, temp = 0; k < count; k++){ temp += flags[k]; } if (temp == count){ break; } } return 0; }