的MWE是在聲明時初始化char數組?
#include <iostream>
using namespace std;
int main(void)
{
char array[255];
cout << array[0] << "\n";
cout << array[1] << "\n";
cout << array[2] << "\n";
cout << array[200] << "\n";
cout << array[253] << "\n";
cout << array[255] << "\n";
return 0;
}
和輸出是
\330
^M
`
\215
^@
^@
雖然我不知道爲什麼輸出創建此。但是我可以說 「數組在聲明時被初始化。」?
號這裏沒有初始化。 (因此,你的程序有未定義的行爲,或者可能未指定)。 –
也許你的意思是char數組[256] = {0};' – Ultimater
@ ultimater,不,只是char數組[255]; – yuxuan