Originally Posted by cwr
It runs for me, but it would depend on your input. A file less than 200 "lines" (see below) will cause an uninitialised pointer deference. A file with a sequence of more than 100 non-whitespace characters will cause a buffer overflow.
For a start, an fscanf on "%s" won't read a line, it will read non-whitespace characters until it finds a whitespace character.
Secondly, you are not protecting yourself from a buffer overflow, so any time you find a sequence of more than 100 non-whitespace characters, you'll overflow your buffer array. The easiest way to read a single line at a time is probably with fgets.
Thirdly, you appear to be checking lines[i] for NULL in your print function, but where do you set the last line to null when building the array?
Fourthly, in your sort function, you check for lines[j] to be NULL, but still go from 0-199 in your inner loop (i) regardless. Also, why not just use qsort instead of the O(n^2) sort you're doing now.