Why memset works to initialize 2D array in C++ with zero but failed to set when declared like this `array[n][k+1]={0}`?

56 Views Asked by At

I have initialized an array like this array[n][k+1]={0} where n and k are user input. But I found that it doesn't initialize all index values to zero. While on the other hand memset(array,0,sizeof(array)) works fine. So why this happened?

Because each time I initialised like this array[n][n]={0}, it always works fine. But why not in this case.

0

There are 0 best solutions below