gpt4 book ai didi

在 C 中复制结构元素与复制数组元素

转载 作者:行者123 更新时间:2023-12-03 03:39:11 25 4
gpt4 key购买 nike

正如此问题的答案中所述Copying one structure to another ,我们可以通过简单的赋值将一个结构元素的内容复制到另一个结构元素。e1=e2;

但是这个简单的赋值在复制数组元素时不起作用。有人可以解释一下吗?

谢谢。

最佳答案

数组是 C 语言中的二等公民:不能将数组分配给数组,也不能从函数返回数组。

Chris Torek 在 comp.lang.c 中提供了这样的解释:

"Note that V6 C also did not support struct-valued arguments and struct-valued return values. One might, then, imagine that Dennis figured that any return value that did not fit in a register was too much work to put into the compiler at that point."

关于在 C 中复制结构元素与复制数组元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27660223/

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