I have following question: My compare function in qsort looks like this:
static int compare(const void *arg1, const void *arg2) {
return strcmp((const char *) arg1, (const char *) arg2);
}
This did not work, so I looked up the code example in the man page and I changed it a little bit, so now it looks like this:
static int compare(const void *arg1, const void *arg2) {
return strcmp( *(char * const *) arg1, *(char * const *) arg2);
}
I don't get it why the method of the man page works, because the parameter of strcmp are const char *s1 and const char *s2.
I am pretty new to C, so I find it difficult to understand this. Can someone please explain this to me why only the method of the man pages works.