什么是用C静态和动态数组之间的区别? [英] What is the difference between static and dynamic arrays in C?
本文介绍了什么是用C静态和动态数组之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:结果
是数组名在C中的指针?结果
C ++静态数组与动态数组?
块引用>我学习C和我在不同的是以下两个阵列之间有什么困惑:
int类型的[10];
和
为int * B =(INT *)malloc的(10 * sizeof的(INT));
刚上最基本的层面,什么是这两者之间有什么区别?
解决方案int类型的[10];
分配堆栈并且作为范围结束后立即解除分配
为int * B =(INT *)malloc的(10 * sizeof的(INT));
被分配在堆和在整个程序的生存活着除非其明确地自由ð
Possible Duplicate:
Is array name a pointer in C?
C++ Static array vs. Dynamic array?I'm learning C and I'm confused at what the difference is between the following two arrays:
int a[10];
and
int *b = (int *) malloc(10 * sizeof(int));
Just on the most basic level, what is the difference between these two?
解决方案int a[10];
is allocated on stack and is de-allocated as soon as the scope ends.
int *b = (int *) malloc(10 * sizeof(int));
is allocated on heap and is alive throughout the lifetime of the program unless it's explicitly freed.
这篇关于什么是用C静态和动态数组之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文