use*_*493 1 c compiler-construction gcc
我有以下程序
main()
{
char a,b;
printf("will i get the job:");
scanf("%c",&a);
printf("%c",a);
printf("We did it");
}
Run Code Online (Sandbox Code Playgroud)
我把文件保存为Hope.c.当我尝试使用gcc编译器编译上面的代码时,我将收到以下错误:
Hope.c:In function 'main':
Hope.c:4:2:warning:incompatible implicit declaration of built-in function 'printf' [enabled by default]
Hope.c:5:2:warning:incompatible implicit declaration of built-in function scanf[enabled by default]
Run Code Online (Sandbox Code Playgroud)
当我使用printf()or时scanf(),编译器会出现此错误,即使在简单的"Hello world"程序中也是如此.
我的代码有问题,或者编译器有问题吗?
你#include <stdio.h>在顶部失踪了.请注意,这些都是警告,而不是错误.您的程序仍应按原样编译.
另外,为了更好地衡量,您应该将返回类型和参数写出到main()并在结尾处返回一个值.
#include <stdio.h>
int main(void)
{
char a,b;
printf("will i get the job:");
scanf("%c",&a);
printf("%c",a);
printf("We did it");
return 0;
}
Run Code Online (Sandbox Code Playgroud)