
二维数组的存储是按行存储,先存第一行,存完后再存储第二行。二位数组仍然是连续的一片存储空间,其中数组名代表数组的开头,a[0][0]
[root@localhost CH01]# cat arr_2d.c
#include<stdio.h>
#include<stdlib.h>
#define M 2
#define N 3
int main()
{
int a[M][N];
int i,j;
for(i = 0; i < M; i++)
{
for(j = 0; j < N; j++)
{
printf("%d",a[i][j]);
}
printf("n");
}
exit(0);
}
[root@localhost CH01]# make arr_2d
cc arr_2d.c -o arr_2d
[root@localhost CH01]# ./arr_2d //由于是auto类型,未赋值时,输出随机
419588804195536
0-169986624032764
[root@localh
最后
以上就是踏实灯泡最近收集整理的关于C语言基础 -26 数组_ 二维数组定义/存储方式的全部内容,更多相关C语言基础内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复