c语言数组的初始化
#include "stdio.h" int main() { int a[3][4]; a[3][4]="1,2,3,4,5,6,7,8,9,10,11,12"; int (*ptr)[4]=a,*p=a[0]; printf("%d",*(ptr+2)+1); return 0; }
例一:先来一个错误的例子
#include "stdio.h" int main() { int a[3][4]; a[3][4]={1,2,3,4,5,6,7,8,9,10,11,12}; printf("%d",a[0][1]); return 0; }
编译不通过
例二:正确的版本
#include "stdio.h" int main() { int a[3][4]={1,2,3,4,5,6,7,8,9,10,11,12}; printf("%d",a[0][1]); return 0; }