[圖解C] Example 812: call by address of 2D array

// Example 812: call by address of 2D array

#include <stdio.h>
#include <stdlib.h>

// 1st dime can be omitted, the other can't be omitted
void print_out(int mat[][5], int, int);

int main()
{
    int array[][5]={{1,2,3,4,5}, {11,22,33,44,55}};
    // using array's name as parameter
    // array name without index, [row][col]
    print_out(array, 2, 5);
   
    system("pause");
    return 0;
}


void print_out(int mat[][5], int row, int col)
{
     int i, j;
   
     for (i=0 ; i<row ; i++){
         for (j=0 ; j<col ; j++){
             printf("%d\t", mat[i][j]);
         }
         printf("\n");
     }
}