#include<stdio.h> //#include<> //二位数组作为函数参数时,可以不指定第一个下标 void print_buf(int (*p)[3],int a,int b) //void print_buf(int p[][3],int a,int b) { int i,j; for(i = 0 ; i < a; i++) { for(j = 0; j < b; j++) { printf("p[%d][%d] = %d ",i,j,p[i][j]); } printf("\n"); } } int main() { int buf[2][3] = {{1,2,3},{4,5,6}}; //几个一维数组,一维数组几个数据 printf("%d %d\n",sizeof(buf)/sizeof(buf[0]),sizeof(buf[0])/sizeof(int)); print_buf(buf,sizeof(buf)/sizeof(buf[0]),sizeof(buf[0])/sizeof(int)); return 0; }
原文地址:https://www.cnblogs.com/wanghao-boke/p/11020388.html
时间: 2024-11-12 16:11:15