I want to initalize a 3 x 3 matrix with first two rows as 0\'s and last row as 1\'s. I have declared a 2D array int matrix[3][3]
int matrix[3][3]
I want to initialize it wit
int matrix[3][3] = { { 0, 0, 0 }, { 0, 0, 0 }, { 1, 1, 1 } };
Or, the more compact:
int matrix[3][3] = { [2] = { 1, 1, 1 } };
The solution generalizes for N so long as N is fixed. If N is large, you can use mouviciel's answer to this question.
N