Ç - 严重放置(的)? [英] C - Badly Placed ()'s?
问题描述
所以我一直试图让这个code。使用采用c GCC编译器来编译(我发现很多到C引用++但没有为C,所以我问这个)我一直得到错误不善放在()的
我每次去运行程序。所以我把它简化为一个非常简单的Hello World的测试程序,我仍然得到同样的错误。
什么引起这个错误?
的#include<&stdio.h中GT;INT主(INT ARGC,为int *的argv [])
{
的printf(的Hello World \\ n);
返回0;
}
看来你是不是要执行该编译后的二进制,但是你有一个运行系统中的的tcsh
和你直接喂C源$ C $ C成壳:
> tcsh的/tmp/badly.c
(记者厉害放置)。
一个C程序必须首先编译为二进制(此处为:的/ tmp /不好
),然后,你必须执行二进制:
> GCC /tmp/badly.c -Wall -o的/ tmp /不好
/tmp/badly.c:3:5:警告:'主'的第二个参数应该是'字符**'[-Wmain]
>的/ tmp /不好
你好,世界
由于ouah已经注意到了他的答案,用 -Wall
参数 GCC
您还可以获得信息的消息你的主
函数的参数是错误的。
So I've been trying to get this code to compile using a gcc compiler using c (I found lots of references to c++ but none to c so I asked this) I kept on getting the error Badly placed ()'s
every time I go to run the program. So I simplified it to a very simple Hello World test program and I still get the same error.
What could be causing this error?
#include <stdio.h>
int main(int argc, int* argv[])
{
printf("Hello World\n");
return 0;
}
It seems that you are not trying to execute the compiled binary, but that you have a system that runs a tcsh
and you are feeding the C source code directly into that shell:
> tcsh /tmp/badly.c
Badly placed ()'s.
A C program must first be compiled to a binary (here: /tmp/badly
), and then you have to execute that binary:
> gcc /tmp/badly.c -Wall -o /tmp/badly
/tmp/badly.c:3:5: warning: second argument of 'main' should be 'char **' [-Wmain]
> /tmp/badly
Hello World
As ouah already noticed in his answer, with the -Wall
argument to gcc
you also get the informative message that the parameters of your main
function are wrong.
这篇关于Ç - 严重放置(的)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!