当我要求查看cc的当前版本时,我得到了这个.
$ cc --version
cc (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$
Run Code Online (Sandbox Code Playgroud)
我想知道的是使用c89,c90,c99或c11中的哪一个.
我有这个c文件
#include <stdio.h>
int main(int argc, char *argv[])
{
int x,i,sum;
sum = 0;
FILE *fin;
fin = fopen("testdata1", "r");
for (i = 0; i < 20; i++ ){
fscanf(fin, "%d", &x);
sum += x;
}
printf("Sum = %d", sum);
fclose(fin);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我通过编译它 gcc -ansi -pedantic -Wall app.c -o app
在编译时,我不断收到此警告错误
警告:ISO C90禁止混合声明和代码[-Wdeclaration-after-statement] FILE*fin; 生成^ 1警告.
有关如何阻止它的任何提示?
我尝试使用-gcc它编译它,它按预期工作,但添加时-pedantic,它将无法编译.我还是编程的初学者,这是我第一次遇到这个问题所以对我来说这是一个很大的问题.
以下是导致错误的代码:
char *exercise[5]={"swimming", "running", "brisk walking", "weight lifting", "zumba"};
Run Code Online (Sandbox Code Playgroud)
如果您能解释解决方案的内容而不仅仅是固定代码,我会很感激,因为我想学习.