2017-03-01 73 views
-1

我想在gnu-linux操作系統中編譯一個c文件,但是當我嘗試編譯這些代碼時,編譯器給了我一些錯誤。爲什麼我在c程序中遇到流浪'342'錯誤?

我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 

在此先感謝您。

+2

不能使用在源文件中的 「智能」 引號。 –

+0

編譯器錯誤的第一件事是不要進入Stack Overflow並詢問它,但要在Google搜索中輸入確切的錯誤並打開第一個鏈接。 –

+0

這些錯誤來自源代碼中的擴展ASCII字符,這是語法所不允許的。 –

回答

2

在c中爲字符串表示使用正確的引號。

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

而不是

printf(「command line argument [%d] = %s \n」, i, argv[i]); 
相關問題