我在学甲鱼大大的c语言视频,碰到一些问题,求解答
我没有用甲鱼大大的vc6,因为我没有在论坛找到视频中下载软件的地方,所以我用的是大学里面老师发的c-free,但是应该都一样吧?我打的代码应该和他在视频中的代码一模一样
int max(int a,int b);
main()
{
int x,y,z
int max(int a,int b);
printf("input two numbers:\n");
scanf("%d%d",&x,&y);
z=max(x,y);
printf("maxmun=%d",z);
}
int max(int a,int b)
{
if(a>b)return a;else return b;
}
然后下面提升我 parse error before ‘int’
implicit declaration of fuction ‘int printf(...)’
这个应该怎么处理,新手小白,不喜勿喷 第四行后面少了个分号
int x,y,z; 本帖最后由 zltzlt 于 2020-2-21 13:33 编辑
改了就可以了:
#include <stdio.h>
int max(int a, int b);
main()
{
int x, y, z;
int max(int a, int b);
printf("input two numbers:\n");
scanf("%d%d", &x, &y);
z = max(x, y);
printf("maxmun=%d", z);
}
int max(int a, int b)
{
if (a > b)
return a;
else
return b;
} zltzlt 发表于 2020-2-21 13:30
第四行后面少了个分号
int x,y,z;
那么另外一个呢
夜邪狼 发表于 2020-2-21 13:31
那么另外一个呢
哪个? zltzlt 发表于 2020-2-21 13:32
哪个?
implicit declaration of fuction ‘int printf(...)’ 夜邪狼 发表于 2020-2-21 13:32
implicit declaration of fuction ‘int printf(...)’
用我那段代码就没报错了 夜邪狼 发表于 2020-2-21 13:32
implicit declaration of fuction ‘int printf(...)’
还有一个implicit declaration of fuction ‘int scanf(...)’ zltzlt 发表于 2020-2-21 13:33
用我那段代码就没报错了
为什么呢
能不能解释一下原因呢,谢谢 本帖最后由 zltzlt 于 2020-2-21 13:35 编辑
夜邪狼 发表于 2020-2-21 13:34
为什么呢
能不能解释一下原因呢,谢谢
1. 你没有导入标准库 stdio.h
2. 漏了分号 zltzlt 发表于 2020-2-21 13:34
1. 你没有导入标准库 stdio.h
2. 漏了分号
虽然我听不懂,但是还是不行,用你的任然报错 夜邪狼 发表于 2020-2-21 13:35
虽然我听不懂,但是还是不行,用你的任然报错
#include <stdio.h>
int max(int a, int b);
main()
{
int x, y, z;
int max(int a, int b);
printf("input two numbers:\n");
scanf("%d%d", &x, &y);
z = max(x, y);
printf("maxmun=%d", z);
}
int max(int a, int b)
{
if (a > b)
return a;
else
return b;
} zltzlt 发表于 2020-2-21 13:35
哦哦,我懂了,谢谢大佬 夜邪狼 发表于 2020-2-21 13:36
哦哦,我懂了,谢谢大佬
请设置最佳答案。
页:
[1]