Initializing 2d array bug in C++

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}.

I’ve run this in multiple places (ex. Real-Time Collaborative Online IDE) and I’ve yet to see a time where it doesn’t produce all 0s. Could you provide a link to an online IDE where this behavior occurs?

I think it’s a problem on Windows.

Which compiler are you using?

MinGW for vscode

Weird, I ran it through the link you provided and the error was present. Maybe its an problem within the OS?

Ide is hosted on Ubuntu Linux FWIW

My bad, it didn’t seem to show up because I was running on larger values of n and m. Idk :man_shrugging: