int main() { char mem[ARRAY_MAX_LENGTH]; char *linePointer[MAX_LINES]; int lines = myreadlines(linePointer, mem, MAX_LINES, ARRAY_MAX_LENGTH); int i; for (i = 0; i < lines; ++i) printf("%s", linePointer[i]); return 0; }
main() { int nlines; char linestore[MAXSTORE]; /* array for storing all lines */ /* myreadlines will pass an extra parameter linestore for storing all the input lines */ if ((nlines = myreadlines(lineptr, MAXLINES, linestore)) >= 0) { qsort(lineptr, 0, nlines-1); writelines(lineptr, nlines); return 0; } else { printf("error: input too big to sort\n"); return 1; } }