求助,为什么数组大小在主函数和子函数里不一样?
程序代码:
#include<stdio.h> void access(int a[][3],int row){ printf("in access_sizeof(a)=%d\n",sizeof(a)); printf("in access_sizeof(*a)=%d\n",sizeof(*a)); int rank=(sizeof(a)/sizeof(*a)); for(int i=0;i<rank;i++){ for(int j=0;j<row;j++){ printf("%d\t\t",a[i][j]); } printf("\n"); } } int main(){ int a[4][3]={{1,2,3},{4,5,6},{7,8,9},{10,11,12}}; printf("in main_sizeof(a)=%d\n",sizeof(a)); printf("in main_sizeof(*a)=%d\n\n",sizeof(*a)); access(a,3); return 0; }