#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);
}
這裏所有的函數調用都給出相同的輸出。甚至p, fun, *fun
都給出了相同的地址。我們如何解釋這一點?爲什麼這個C程序中所有的輸出都是一樣的?
How can fun and *fun be same?
在古代,當你不得不使用* fun來取消引用函數指針時,但是C的作者認爲樂趣是明確的,並且使它變得如此有趣(2)會起作用嗎? –