为什么我会在 C 程序中遇到杂散的“342”错误?
Why am I getting the stray '342' error in the C program?
我试图在 GNU/Linux 操作系统中编译一个 C 文件,但是当我尝试编译这段代码时,编译器给我一些错误。
我的op.c文件是这样的:
#include <stdio.h>
int main(int argc, char *argv[]){
int i;
for (i=0; i < argc; i++){
printf(“command line argument [%d] = %s \n”, i, argv[i]);
}
return 0;
}
当我尝试编译这段代码时,出现了这些错误。我该如何修复它们?
op.c: In function ‘main’:
op.c:6:3: error: stray ‘2’ in program
printf(“command line argument [%d] = %s \n”, i, argv[i]);
^
op.c:6:3: error: stray ‘0’ in program
op.c:6:3: error: stray ‘4’ in program
op.c:6:13: error: ‘command’ undeclared (first use in this function)
printf(“command line argument [%d] = %s \n”, i, argv[i]);
^
op.c:6:13: note: each undeclared identifier is reported only once for each function it appears in
op.c:6:21: error: expected ‘)’ before ‘line’
printf(“command line argument [%d] = %s \n”, i, argv[i]);
^
op.c:6:21: error: stray ‘\’ in program
op.c:6:21: error: stray ‘2’ in program
op.c:6:21: error: stray ‘0’ in program
op.c:6:21: error: stray ‘5’ in program
在 C 中使用正确的引号表示字符串。
printf("command line argument [%d] = %s \n", i, argv[i]);
而不是
printf(“command line argument [%d] = %s \n”, i, argv[i]);
我试图在 GNU/Linux 操作系统中编译一个 C 文件,但是当我尝试编译这段代码时,编译器给我一些错误。
我的op.c文件是这样的:
#include <stdio.h>
int main(int argc, char *argv[]){
int i;
for (i=0; i < argc; i++){
printf(“command line argument [%d] = %s \n”, i, argv[i]);
}
return 0;
}
当我尝试编译这段代码时,出现了这些错误。我该如何修复它们?
op.c: In function ‘main’:
op.c:6:3: error: stray ‘2’ in program
printf(“command line argument [%d] = %s \n”, i, argv[i]);
^
op.c:6:3: error: stray ‘0’ in program
op.c:6:3: error: stray ‘4’ in program
op.c:6:13: error: ‘command’ undeclared (first use in this function)
printf(“command line argument [%d] = %s \n”, i, argv[i]);
^
op.c:6:13: note: each undeclared identifier is reported only once for each function it appears in
op.c:6:21: error: expected ‘)’ before ‘line’
printf(“command line argument [%d] = %s \n”, i, argv[i]);
^
op.c:6:21: error: stray ‘\’ in program
op.c:6:21: error: stray ‘2’ in program
op.c:6:21: error: stray ‘0’ in program
op.c:6:21: error: stray ‘5’ in program
在 C 中使用正确的引号表示字符串。
printf("command line argument [%d] = %s \n", i, argv[i]);
而不是
printf(“command line argument [%d] = %s \n”, i, argv[i]);