函数指针的问题,求救.
ascap 2005-05-30 10:30:40 代码如下:
void main(void)
{
void (*fp)(const char *,...);
fp=(void)printf;
(*fp)("this is good.\n%s\n","love");
}
显示错误为:
ompiling...
Console.cpp
E:\MyWorkDir\Project\Console\Console.cpp(17) : error C2440: '=' : cannot convert from 'void' to 'void (__cdecl *)(const char *,...)'
Expressions of type void cannot be converted to other types
Error executing cl.exe.
Console.exe - 1 error(s), 0 warning(s)
如果我把void (*fp)(const char *,...);更改为int(*fp)(const char *,...);就没有错误.
但我现在就是要用void (*fp)(const char *,...)来实现,请问有什么办法吗?