The following code snippet is from K&R Chapter 5-11: Pointers to Functions:
qsort((void**) lineptr, 0, nlines-1,
(int (*)(void *, void *)(numeric ? numcmp : strcmp));
I am able to compile/run the code with (void*)
so why is lineptr cast with (void **)
instead? Are there any internal differences between the two casts or is it more for readability? Is (void *)
casting just the array whereas (void **)
is casting both the array and stored pointers?
I understand **lineptr
is equivalent to *lineptr[]
and the reason for void cast is to make the compiler happy.