我在一本书中发现了这个问题。任何人都可以请解释C程序的输出?
问题:
以下程序的输出是什么?
#include <stdio.h>
int fun(int,int);
typedef int(*pf) (int,int);
int proc(pf,int,int);
int main()
{
printf("%d\n",proc(fun,6,6));
return 0;
}
int fun(int a,int b){
return (a==b);
}
int proc(pf p,int a,int b){
return ((*p)(a,b));
}
此代码在运行时,打印出1
我试图理解它,但没有它是没有用的。这个程序中发生了什么,为什么它输出1?
在此先感谢。
这看起来像功课,我 – Petesh 2012-04-05 08:55:43
的答案是:'0'! – leppie 2012-04-05 09:14:30