Hey guys,
I am trying to initialize a 2D array in C. For example, I have the matrix:
0 1 0 0
0 1 1 0
1 0 1 1
0 1 1 1
Now I think this would work:
But this is a real pain. I will have larger matrices like 17x17 and doing this would be a real annoyance.Code:int A[4][4]; A[0][0] = 0; A[0][1] = 1; A[0][2] = 0; A[0][3] = 0; A[0][4] = 0; A[1][1] = 0; A[1][2] = 1; ... ETC.... A[4][4] = 1;
Is there a way to do something like:
?Code:int A[4][4] = {0 1 0 0; 0 1 1 0, ... etc}
Thanks!