【发布时间】:2013-05-27 20:07:50
【问题描述】:
所以我有以下内容:
int from[2][3] = { {1,2,3}, {2,3,4} };
int into[3];
into = memcpy(into, from[0], 3 * sizeof(*into));
我想将 'from' in 复制到数组 'into' 中,这样 'into' = { 1, 2, 3}
我正在尝试使用 memcpy 执行上述操作(我知道它已经使用循环),但我似乎无法让它工作。
我不断收到错误:
error: incompatible types when assigning to type ‘int[3]’ from type ‘void *’
我找到了这个问题的链接:
How do I copy a one-dimensional array to part of another two-dimensional array, and vice-versa?
并更改了我的代码(上),但我仍然收到错误。
我仍然一无所知,我已经以另一种方式解决了我的问题,但我很想知道它是如何完成的,因为从上一篇文章中我知道这是可能的。
【问题讨论】:
标签: c arrays multidimensional-array memcpy