Possible Duplicate:
How does dereferencing of a function pointer happen?
void myprint(char* x) {
printf("%s\n", x);
}
int main() {
char* s = "hello";
void (*test)(char*);
void (*test2)(char*);
test = myprint;
test2 = &myprint;
test(s);
(*test)(s);
test2(s);
(*test2)(s);
}
Can anyone explain to me why all of the above code is valid? "hello" is printed four times. By applying the function pointer, is it implicitly derefenced? Basically I want to know how function pointers are actually stored, because the above is kind of confusing.