int main()
{
int b[2][3]={{1,2},{3,4,5}};
cout << b[0][2] << endl;
}
And the result in both visual and g++ is 0! Why? I thought it must be another number!
For example, when we define int a[5] then we say cout << a[3]; without setting a[3], it will be something like, 0123984283 which means the last value of this cell in the RAM.
But here, What’s the reason of 0?
If it is Partial Initialization, yes rest of the elements are guaranteed to be 0.
Here is a good read for Standerdese Fans and ones with eye for detail:
C and C++ : Partial initialization of automatic structure