The qsort(3) library routine's man page shows an example of sorting words specified as arguments on the command line. The comparison function is read as follows:
static int cmpstringp(const void *p1, const void *p2) { return strcmp(* (char * const *) p1, * (char * const *) p2); }
But what is sorted here is the argv elements. argv is now a pointer to character pointers, which can also be viewed as a table of character pointers.
Therefore, its elements are pointers to characters, so shouldn't the actual arguments to cmpstringp point to characters, and not "pointers to pointers to char"?
source share