乳鼠:老师们,帮忙看一下,是错再哪?

来源:百度文库 编辑:高校问答 时间:2024/05/12 06:19:46
main()
{
long a,b,c,d;
printf("please input three number,\n");
scanf("%ld,%ld,%ld",&a,&b,&c);
d=max(a,b,c);
printf("d is %ld",d);
getch();
}

long max(long x,long y,long z)
{
long v;
if(x>y) v=x;
else v=y;
if(v>z) return(v);
else return(z);
}

编译的时候.error:Type mismatch in redeclaration of 'max'

呵呵 知道了 你在main()上面再添一句long max(long x,long y,long z);
分号不可省略 即可

假如函数是在main后面定义的,必须在main之前声明一下
举例见楼上

这个就是函数声明的问题了
c语言中函数必须先定义后使用,或者先声明在使用
这个和c++是不一样的,c++是不需要先声明的,使用后在定义也可以!1