Possible Duplicate:
function call with different semantics
I am reading about function pointers in C. I tried this program:
#include <stdio.h>
int foo(void)
{
printf("At foo.");
return 0;
}
int main (void)
{
printf("%p\t%p\t%p\n", &foo, foo, *foo);
return 0;
}
The output for this program is:
0040138C 0040138C 0040138C
In 1-D array <datatype> <identifier>[N], identifier and &identifier points to the same value but the nature of the values are different. One is of type datatype* and the other is of type pointer to the 1-D array. Analogously, for functions, the foo and &foo are the same. But what about *foo and what is the nature of &foo, foo, *foo?
A plain
foois already a function pointer:You may obtain the address of a function using
&, which yields apointer to function ...:It’s legal to apply the indirection operator to a function designator:
tldr:
So there you have it. They all do the same thing.
EDIT
Quick! To the standard!