問題:
從網上拷貝了一段代碼,粘貼到自己寫的程序strcat_compare.c中,然後編譯gcc -o strcat_compare strcat_compare.c;
出現錯誤如下:
代碼如下:
avid@ubuntu:~/wrk/tmp$ gcc -o strcat_compare strcat_compare.c
strcat_compare.c: In function ‘main':
strcat_compare.c:28:1: error: stray ‘\343' in program
strcat_compare.c:28:1: error: stray ‘\200' in program
strcat_compare.c:28:1: error: stray ‘\200' in program
strcat_compare.c:28:1: error: stray ‘\343' in program
strcat_compare.c:28:1: error: stray ‘\200' in program
strcat_compare.c:28:1: error: stray ‘\200' in program
strcat_compare.c:30:1: error: stray ‘\343' in program
strcat_compare.c:30:1: error: stray ‘\200' in program
strcat_compare.c:30:1: error: stray ‘\200' in program
strcat_compare.c:30:1: error: stray ‘\343' in program
strcat_compare.c:30:1: error: stray ‘\200' in program
strcat_compare.c:30:1: error: stray ‘\200' in program
strcat_compare.c:32:1: error: stray ‘\343' in program
strcat_compare.c:32:1: error: stray ‘\200' in program
strcat_compare.c:32:1: error: stray ‘\200' in program
strcat_compare.c:32:1: error: stray ‘\343' in program
strcat_compare.c:32:1: error: stray ‘\200' in program
strcat_compare.c:32:1: error: stray ‘\200' in program
david@ubuntu:~/wrk/tmp$
運行環境:ubuntu 11.10;
解決辦法:
1. 放狗搜,說可能程序本身的語法沒有問題,但是,出錯行中包含不被識別的字符,比如空格的格式不對;
2. 將程序中出錯行前面的空格刪除,重新插入空格或tab鍵,重新編譯,錯誤消失。
ok,問題解決。