When I was fixing a wrong test case of a problem, I ran this code to check the initialization of an array I created.
#include <bits/stdc++.h>
using namespace std;
int main() {
int n=30; int m = 10;
int times[n][m]={0};
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
cout<<times[i][j]<<" ";
}
cout<<endl;
}
}
I noticed that even though I had declared the first value to be 0, which I read online should make every value in the array 0, the first row was full of randomized integers (besides the first value). Is there something I’m missing? This problem disappears when I set the first value to {} rather than {0}.