Warning: missing braces around initialize means you are not using inner braces in a multidimensional array
Let’s see an example
For instant, 2D array initialization without using inner braces
int array[4][2]={1,2,3,4,5,6,7,8};
As can be seen, from the above 2D array initialization that it is initialized without using inner braces because of that the compiler throws a warning
At this time, 2D array initialization by using inner braces
int array[4][2]={ {1,2}, {3,4}, {5,6}, {7,8} };
In the same way, 3D array initialization without using inner braces
int array_3d[2][3][2] = {0,1,2,3,4,5,6,7,8,9,0,11};
As I have said, when you don’t use inner braces during 3D array initialization then at that instant, the compiler will throw a warning
3D array initialization by using inner braces
// initializing the 3-dimensional array int array_3d[2][3][2] = { { { 0, 1 }, { 2, 3 }, { 4, 5 } }, { { 6, 7 }, { 8, 9 }, { 10, 11 } } };
Leave a Reply