gpt4 book ai didi

c - malloced数组VS。变长数组

转载 作者:太空狗 更新时间:2023-10-29 16:23:27 25 4
gpt4 key购买 nike

<分区>

一开始大小未知的数组有两种分配内存的方法。最常见的方法是像这样使用 malloc

int * array;
... // when we know the size
array = malloc(size*sizeof(int));

但在 C99 中,在我们知道大小后定义数组也是有效的。

... // when we know the size
int array[size];

它们绝对相同吗?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com