为什么我会得到流浪的Ř 342' c程序中的错误?

时间:2017-03-01 16:25:32

标签: c compiler-errors gnu

我正在尝试在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 ‘\342’ in program
   printf(“command line argument [%d] = %s \n”, i, argv[i]); 
   ^
op.c:6:3: error: stray ‘\200’ in program
op.c:6:3: error: stray ‘\234’ 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 ‘\342’ in program
op.c:6:21: error: stray ‘\200’ in program
op.c:6:21: error: stray ‘\235’ in program

谢谢您的预付款。

1 个答案:

答案 0 :(得分:2)

在c。

中使用正确的引号表示字符串
printf("command line argument [%d] = %s \n", i, argv[i]); 

而不是

printf(“command line argument [%d] = %s \n”, i, argv[i]);