The second argument that you pass to qsort should be the number of elements to be sorted. You are passing 0 which means no elements will get sorted. To sort the whole lineptr array you should pass MAXLINES as the second argument.
The compare function is not correct. p1 and p2 are pointers to the line pointers that are stored in the lineptr array. *p1 and *p2 gives you the char pointers in lineptr. **p1 and **p2 gives you the characters.
But you can't simply add an extra dereference operator wherever you use p1 and p2 because doing (*p1)++ (*p2)++ will modify the pointers in the lineptr array and because you have casted away the const from the pointers the compiler would not have told you this was wrong.
What you could do is to dereference the pointers that are passed to the function so that you get copies of the line pointers, and then you can increment them without problem.