问一个函数指针的问题,通不过编译~~~

spearous 2006-02-13 06:25:45
程序如下:
#include <stdio.h>

int max(int first ,int second);

int main()
{
int x1=8,x2=10;
int (*p)(int,int);
p=&max;
printf("%d",(*p)(x1,x2));
return 0;
}

int max(int first,int second);
{
if(first>=second)
return first;
else return second;
}


VC6编译结果是 max函数 error C2447: missing function header (old-style formal list?)

不懂,请大家帮忙 ~~~3x~~~
...全文
110 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
caijize 2006-02-14
  • 打赏
  • 举报
回复
printf("%d",(*p)(x1,x2));
==========================
直觉告诉我应该是printf("%d,p(x1,x2));
不用加*号。
fine10000 2006-02-14
  • 打赏
  • 举报
回复
都会阴沟里翻船的,别灰心。
yuzl32 2006-02-14
  • 打赏
  • 举报
回复
无颜了,唉~~~
spearous 2006-02-14
  • 打赏
  • 举报
回复
无颜了,唉~~~
sankt 2006-02-13
  • 打赏
  • 举报
回复
#include <stdio.h>

int max(int first ,int second);

int main()
{
int x1=8,x2=10;
int (*p)(int,int);
p=&max;
printf("%d",(*p)(x1,x2));
return 0;
}

int max(int first,int second) //这里去掉分号
{
if(first>=second)
return first;
else return second;
}
huang1204 2006-02-13
  • 打赏
  • 举报
回复
int max(int first,int second);
{
if(first>=second)
return first;
else return second;
}
去掉分号
huang1204 2006-02-13
  • 打赏
  • 举报
回复
int max(int first,int second); 去掉后面的分号

33,321

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧