int main() { int a[3][2] = {1,2,3,4,5,6}; print1(a); return 0; }错误范例:
void print1(int **b)
void print1(int b[3][])
void print1(int (&b)[3][2])2.指定行和列
void print2(int b[3][2])3. 指定列
void print3(int b[][2])
#include <stdio.h> #include <stdlib.h> void print1(int (&b)[3][2], int row, int col) { printf("Run print1\n"); for (int i = 0; i < row; i++) for (int j = 0; j < col; j++) printf("%d\n", b[i][j]); } void print2(int b[3][2], int row, int col) { printf("\nRun print2\n"); for (int i = 0; i < row; i++) for (int j = 0; j < col; j++) printf("%d\n", b[i][j]); } void print3(int b[][2], int row, int col) { printf("\nRun print3\n"); for (int i = 0; i < row; i++) for (int j = 0; j < col; j++) printf("%d\n", b[i][j]); } int main() { int a[3][2] = {1,2,3,4,5,6}; print1(a, 3, 2); print2(a, 3, 2); print3(a, 3, 2); system("pause"); return 0; }
原文:http://blog.csdn.net/quzhongxin/article/details/43496385