1

If a function name is a pointer to itself, why is the function name with & operator also an address of the function? Is it not the address of pointer to the function?

 void f(int a);

    // ....
    void(*P)(int)=&f;
    P(2); // why(*p)(2) is also correct?
Zahra19977
  • 355
  • 1
  • 12
  • Because you get the address of the function. Invoking functions in assembly language is nothing but jumping to the function address and continueing from there.. – Neijwiert Apr 25 '18 at 12:36
  • @Neijwiert I think he meant: `addressof(Function) != addressof(&Function)` but the left is just sugar for the right. – NaCl Apr 25 '18 at 12:37
  • 1
    @NaCl Oh I see, then I misread the question. – Neijwiert Apr 25 '18 at 12:41
  • For op: the last declaration of your function pointer is: `int (*p)(int)` which is not the same as `void f(int)`, note the return type, ***pretty strict C code*** would not allow this kind of stuff. – NaCl Apr 25 '18 at 12:44
  • @NaCl yes i maked mistake...i edited – Zahra19977 Apr 25 '18 at 12:52

0 Answers0