Like using an array name, using a function name will cause it to break into a pointer at the slightest provocation.
s.pt_1 = function;
Here function decays to a pointer to a function.
s.pt_2 = &function;
Here you actually take the address of the function, which leads to the same pointer as in the first case.
printf("%x\n",s.pt_1); //Result: 0x013011a9 printf("%x\n",*s.pt_1); //Result: 0x013011a9 printf("%x\n",**s.pt_1); //Result: 0x013011a9
The first line of pt_1 indicates the function pointer, and the address stored in the pointer is displayed.
In the second line, you look for a pointer and get access to the function itself. Which breaks into a pointer when passing a function.
On the third line, you search for a pointer to get a function that then decays to a pointer when you use it with another * . The second star results in a value that goes back to the pointer when the function is passed. Etc.
Bo persson
source share