Divide it in parts ...
myFunction takes a pointer to a pointer of type void (which pretty much means that it can point to anything). It could be declared something like this:
myFunction(void **something);
Everything you go through must be of this type. So you take the address of the pointer and drop it (void **) to make it a pointer to void. (Basically, depriving him of any idea of what he points to - which the compiler might whine otherwise.)
This means that the & variable is the address (& does this) of the pointer, so the variable is the pointer. To what? Who knows!
Here's a more complete snippet to give an idea of how this fits together:
#include <stdio.h> int myInteger = 1; int myOtherInt = 2; int *myPointer = &myInteger; myFunction(void **something){ *something = &myOtherInt; } main(){ printf("Address:%p Value:%d\n", myPointer, *myPointer); myFunction((void**)&myPointer); printf("Address:%p Value:%d\n", myPointer, *myPointer); }
If you compile and run this, it should provide this output:
Address:0x601020 Value:1 Address:0x601024 Value:2
You can see that myFunction changed the value of myPointer - which it could only do because the pointer address was passed to it.
Kim reece
source share