EDIT2: I'm an idiot I accidentally had float **matrix instead of float (*matrix)[3]. caf had the right answer all along.
Is this what you want?
#include <stdio.h> #include <stdlib.h> void print_matrix(float (*matrix)[3], size_t rows, size_t cols) { int i, j; for (i = 0; i < rows; i++) for (j = 0; j < cols; j++) printf("%f ", matrix[i][j]); } int main(void) { float ar[][3] = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} }; print_matrix(ar, 3, 3); return EXIT_SUCCESS; }
EDIT: you can also have:
float *row1, *row2, *row3; row1 = ar[0]; row2 = ar[1]; row3 = ar[2]; ... float row1_total = row1[0] + row1[1] + row2[2];