gpt4 book ai didi

c - 在 C 中,像这样复制数组是不可能的。为什么?和最好的技巧

转载 作者:太空狗 更新时间:2023-10-29 15:42:41 24 4
gpt4 key购买 nike

int x[10],y[10];
x = y;

我正在考虑一个简单的 hack,它可以让我获得这种效果。

最佳答案

您可以将它们包装在 struct 中以使用简单的赋值:

struct foo { int a[10]; } x, y;
x = y;

但实际上,只需使用memcpy

关于c - 在 C 中,像这样复制数组是不可能的。为什么?和最好的技巧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2170926/

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