gpt4 book ai didi

c - 分配之间的差异

转载 作者:太空狗 更新时间:2023-10-29 15:52:50 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Difference between declaration and malloc

这两个程序有区别吗?

int main(void) {
char str[80];
}

int main(void) {
char * str = (char*) malloc( sizeof(char) * 80 );
}

那么使用malloc 和类似数组的语法有区别吗?所以如果我需要 80 个字符的内存,我应该使用 malloc 而不是其他可能性,对吗?

我会尝试回答我自己的问题!

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