【发布时间】:2010-12-04 11:48:53
【问题描述】:
我有这个代码:
#include <stdio.h>
int getAns(void);
int num;
int main()
{
int (*current_ans)(void);
current_ans = &getAns;
// HERE
printf("%d", current_ans());
}
int getAns()
{
return num + 3;
}
但是,是否有可能在 // HERE 点中有一些东西允许下一行是 printf("%d", current_ans);,它以迂回的方式访问 getAns()?
【问题讨论】:
-
不完全是您想要的,但如果您不知道 - 您可以执行
int v = current_ans();然后将v传递给 printf。
标签: c pointers function macros parentheses