I have this method for prinitng:
void printMatrix(int matrix[][3]){ int i = 0, j = 0; int leni, lenj; leni = sizeof matrix / sizeof matrix[0][0]; lenj = sizeof (matrix[0]) / sizeof (matrix[0][0]); for(i = 0 ; i < leni ; i++) { for(j = 0 ; j < lenj ; j++) { printf("%d ", matrix[i][j]); } printf("\n"); } printf("\n"); }
and a matrix:
int A[2][3] = {{1, 3, 4}, {2, 0, 1}, and this method writes me my matrix only for 2 x 3, I was making a research and leni and lenj return quite bad numbers, problem will be in void vypisMatice(int matrix[][3]){ where I am declaring matrix with number of columns, but without that number, compiler won't compile my app. I just want to know how to adjust my method to accept matrix of any size when printing, like printMatrix(A);?
Thanks