Most likely my expression:
int arr[][2]={1,2,3};
appears to be legal. You can legally omit internal curly braces in initializers. For example, if you want to explicitly define the boundaries of arr and initialize all its elements, you can write either:
int arr[2][2] = { { 1, 2}, { 3, 4 } };
or, equivalently:
int arr[2][2] = { 1, 2, 3, 4 };
You can also lower the engaging elements and they will be implicitly set to zero. For a one-dimensional array, this is straightforward; this is:
int arr[4] = { 1, 2, 3 };
is equivalent to:
int arr[4] = { 1, 2, 3, 0 };
And if you omit the measurement, this can be done from the initializer:
int arr[] = { 1, 2, 3, 4 };
Since you define arr as an array of 2 element int arrays, this is:
int arr[][2]={1,2,3};
equivalent to this:
int arr[][2] = { { 1, 2 }, { 3 } };
There are two elements in the initializer (each of which initializes a 2-element array), which is equivalent to:
int arr[2][2] = { { 1, 2 }, { 3 } };
Finally, you missed the last subitem of the initializer, so it is implicitly zero:
int arr[2][2] = { { 1, 2 }, { 3, 0 } };
In general, omitting dimensions and finalizing initializers is useful because it allows the compiler to figure out some things. If I write:
char message[] = "hello, world";
I don't need to count the characters in the string (and add 1 for the trailing '\0' ). Computers are really good at counting things; having made a man, this work will be stupid.
Similarly, omitting some initializers allows you to provide only the necessary information. With the addition of C99 designated initializers, you can even initialize a specific member of the structure and let the compiler take care of the rest:
struct foo obj = { .something = 42 };
Regarding the alignment of initializers, omitting the internal curly braces, I personally do not see much sense for this, except in the special case of using the initializer { 0 } for initialization and a full array or structure to zero. In particular, for multidimensional arrays, I find it much clearer to show the entire structure of the array.