If i have a, for example, 3x3 matrix, i declare it like this:
int array [] [3] = { {1,2,3}, {4,5,6},{7,8,9}}
But what if my matrix is like this:
{{1,2},{3,4,5,6,7,8},{1}}
Also, why is this:
Code:
displaying random numbers in printf instead of the array's elements?
also, this:
printf ( "%d %d\n\n", array [1][1], array [1][2]);
displays 5 and 6. what am i doing wrong?
EDIT:
If this is of any help, I used this:
Code:
to display the array, and the rows and columns always have 4 elements
if the number of rows and columns is smaller than 4 in the declaration, some numbers get a random value, if the number is greater or equal to 4, they get 0.
EDIT: Nevermind my second question, I solved it. The first one is still open tho
int array [] [3] = { {1,2,3}, {4,5,6},{7,8,9}}
But what if my matrix is like this:
{{1,2},{3,4,5,6,7,8},{1}}
Also, why is this:
Code:
{
int array [3] [3] = {{1,2,3},{4,5,6}, {7,8,9}};
printf ( "%d %d\n\n", array [3][1], array [3][2]);
}
displaying random numbers in printf instead of the array's elements?
also, this:
printf ( "%d %d\n\n", array [1][1], array [1][2]);
displays 5 and 6. what am i doing wrong?
EDIT:
If this is of any help, I used this:
Code:
{
int i,j;
int array [] [3] = {{1,2,3},{4,5,6},{7,8,9}};
for (i=0; i<=3 ; i++)
for (j=0; j<=3 ; j++)
{
printf( "%d ", array [i][j]);
if (j==3)
putchar ( '\n');
}
}
to display the array, and the rows and columns always have 4 elements
if the number of rows and columns is smaller than 4 in the declaration, some numbers get a random value, if the number is greater or equal to 4, they get 0.
EDIT: Nevermind my second question, I solved it. The first one is still open tho