開發平台(Platform): (Ex: Win10, Linux, ...)
Win10
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
GCC
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
none
問題(Question):
使用sizeof判斷陣列的大小 無論是多少個字元 都是顯示8 bytes
餵入的資料(Input):
how
預期的正確結果(Expected Output):
3
錯誤結果(Wrong Output):
8
程式碼(Code):(請善用置底文網頁, 記得排版,禁止使用圖檔)
int main()
{
outstring("How");
}
void outstring(char buffer[])
{
int n = 0;
for (int i = 0; i < sizeof(buffer)/sizeof(buffer[0]); i++)
n++;
printf("buffer have %d characters\n, n);
}
補充說明(Supplement):
最多最多就是讀取8個characters
想了一下還是不太懂為什麼無法使用這個方法
感覺是有什麼觀念漏掉了 希望大家能給予一些觀念上的指導及建議 謝謝大家