0
使用memcpy(),我想复制部分数组到另一个源数组是双指针数组的地方。是否有解决方案来实现这样的复制过程没有更改双指针?两个不同指针之间的memcpy()
int **p;
p= malloc(sizeof(int *));
p= malloc(5 * sizeof(int));
int *arr;
arr= malloc(5 * sizeof(int));
for(i = 0; i < 5; i++){
p[i] = 1;
}
memcpy(arr, (2+p) , 3*sizeof(int)); // I want to start copying 3 elements starting from the third position of the src.
你不分配内存以'arr'。 – ameyCU
对不起,这是一个错误。我的意思是arr –
'p = malloc(sizeof(int *)); p = malloc(5 * sizeof(int));' - 这看起来不正确... –