C语言编译错误问题

[复制链接]
查看11 | 回复3 | 2010-8-6 10:38:12 | 显示全部楼层 |阅读模式
#include
void main()
{
int f(int a,int b);
int i=2,p;
p=f(i,++i);
printf("%d\n",p);
getch();
}
int f(int a,int b)
{
int c
if(a>b)
c=1;
else if(a==b)
c=0;
else c=-1;
return(c);
}
错误原因是:错误 testlo~1.c 13: 说明语法错误在 f 函数中
错误 testlo~1.c 15: 'else' 位置错在 f 函数中
可是我没看出来有什么错误啊、、请高手指教、、我用的是Win—TC

回复

使用道具 举报

千问 | 2010-8-6 10:38:12 | 显示全部楼层
#includemain(){int f(int a,int b);int i=2,p;p=f(i,++i);printf("%d\n",p);getchar();}int f(int a,int b){ int c;//需要输入分号。 if(a>b) {c=1; } else if(a==b) {c=2; } else {c=3; } return c;}
回复

使用道具 举报

千问 | 2010-8-6 10:38:12 | 显示全部楼层
#include#includevoid main(){int f(int a,int b);int i=2,p;p=f(i,++i);printf("%d\n",p);getch();}int f(int a,int b){int c;if(a>b)c=1;el
回复

使用道具 举报

千问 | 2010-8-6 10:38:12 | 显示全部楼层
差个分号。int cif(a>b)改为:int c;if(a>b)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行