我有这个C代码(灵感来自测试)
#include <stdio.h>
int foo (int n)
{
static int s = 0;
return s += n;
}
int main()
{
int y;
int i;
for (i=0; i<5; i++) {
y= foo(i);
}
printf("%d\n", foo);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我特别感兴趣的是它的价值foo
和类型.编译器给了我这个警告
test.c:18:16: warning: format specifies type 'int' but the argument has type
'int (*)(int)' [-Wformat]
Run Code Online (Sandbox Code Playgroud)
但我不确定这意味着什么.什么是int (*)(int)
如何调用没有参数的函数名称给我这种类型的东西?