Why are all outputs the same in this C program?

#include<stdio.h> int main(){ extern void fun(int); void (*p)(int) = fun; fun(2); (*fun)(2); (*p)(2); p(2); printf("%x %x %x\n",p,fun,*fun); } void fun(int i){ printf("hi %d\n",i); } 

Here, all function calls give the same output. And even p, fun, *fun give the same address. How can we interpret this?

 How can fun and *fun be same? 
+4
source share
1 answer

Because C says:

(C99, 6.5.3.2p4) "The unary * operator designates an indirect direction. If the operand points to a function, the result will be the designation of the function:"

fun and *fun have the same meaning as they are equivalent.

+7
source

Source: https://habr.com/ru/post/1442486/


All Articles