Array initialization question
I have a quick question about a code here. In the following code, the array "field" is initialized to equal {0}: "#include <iostream> using namespace std; const int M = 20; const int N = 10; int field[M][N]={0}; int main(){ field[10][5]=1; for(int i = 0; i<M; i++){ for(int j = 0; j<N; j++){ cout<<field[i][j]<<endl; } }; return 0; }" The output was a bunch of 0s until field[10][5], as expected. Then I changed the code slightly here: "#include <iostream> using namespace std; const int M = 20; const int N = 10; int field[M][N]={1}; int main(){ field[10][5]=0; for(int i = 0; i<M; i++){ for(int j = 0; j<N; j++){ cout<<field[i][j]<<endl; } }; return 0; }" This output a single "1" followed by many "0"s. Does this mean uninitialized elements of an array are automatically 0?