當我嘗試編譯時出現此錯誤......我通常不熟悉編碼,所以它可能很明顯,我沒有看到它。
我的代碼是:
#include<stdio.h>
int main ()
{
float x?[7] = 23.0, -28.6, 30.2, 29.0, -8.0, -30.0, 27.8;
int i = 3;
printf ("%.2f \n", x?[i 1]);
return 0;
}
這是一個超級簡單的代碼,只是應該輸出一個數字......但是每次我嘗試編譯時我都會收到這個錯誤:
test.c:4:8: error: stray ‘\342’ in program
float x???[7] = 23.0, -28.6, 30.2, 29.0, -8.0, -30.0, 27.8;
^
test.c:4:9: error: stray ‘\200’ in program
float x???[7] = 23.0, -28.6, 30.2, 29.0, -8.0, -30.0, 27.8;
^
test.c:4:10: error: stray ‘\213’ in program
float x??[7] = 23.0, -28.6, 30.2, 29.0, -8.0, -30.0, 27.8;
^
test.c:6:21: error: stray ‘\342’ in program
printf ("%.2f \n", x???[i 1]);
^
test.c:6:22: error: stray ‘\200’ in program
printf ("%.2f \n", x???[i 1]);
^
test.c:6:23: error: stray ‘\213’ in program
printf ("%.2f \n", x??[i 1]);
知道是什么原因造成的嗎?任何建議,將不勝感激!
謝謝!
uj5u.com熱心網友回復:
您(大概)嘗試從另一個來源復制和粘貼您的代碼,并且該源文本包含一個或多個不可見字符的實體,稱為零寬度空格。這在您的源代碼中無效。您的編譯器將這些字符報告為用于表示它們的底層位元組:在UTF-8 編碼中,零寬度空間使用位元組 0xe2、0x80、0x8b 進行編碼。反過來,這些由編譯器表示為八進制反斜杠轉義序列,給出錯誤訊息中的值。
(修復此問題并不能修復您的程式。您還有另一個語法錯誤:您必須使用大括號({和}符號)將陣列資料括起來。)
uj5u.com熱心網友回復:
你已經錯過了{和}在
float x?[7] = 23.0, -28.6, 30.2, 29.0, -8.0, -30.0, 27.8;
更正的代碼:
float x?[7] = { 23.0, -28.6, 30.2, 29.0, -8.0, -30.0, 27.8 };
現在它會給 ans = -8.00
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/380466.html
標籤:C
上一篇:請問,我怎樣才能找到一個演算法來檢查反轉2個連續字符
下一篇:將float型別轉換為char
