参考:https://blog.csdn.net/msdnwolaile/article/details/50576418

研究了下变量&数组定义时的内存分配,发现不一样,真的顺序还是看编译器:

#include<stdio.h>
int main()
{
	int a[4] = {11,12,13,14};
	int b[4] = {21,22,23,24};
	
	int *pa = &a;
	int i = 0;
	while(i<8)
	{
		i++;
		printf("now *p value = %d and",*pa);
		printf("p addr value = %d \n",pa);
		pa++;
	}
	return 0;
}

运行效果:

C语言——数组内存空间分配

C语言——数组内存空间分配

分析可得:独立数组和数组元素皆是从高到低(gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10))

相关文章:

  • 2021-09-14
  • 2022-12-23
  • 2021-11-13
  • 2021-08-29
  • 2021-12-05
猜你喜欢
  • 2021-08-06
  • 2021-08-04
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
  • 2022-12-23
相关资源
相似解决方案