开发者

Copying 1 Array of Pointer to 2nd Array of Pointer in C

I have two array of pointers and I want to copy one to other

Int32 *Ptr1[2];
Int32 *Ptr2[2];
Int32 a,b;

Ptr1[0]=&a;
Ptr1[1]=&b;

I want Ptr2 to hold Ptr1[0] and Ptr2[1];

Ptr2[0]=Ptr1[0];
Pt开发者_如何学Cr2[0]=Ptr1[1];

Is there any other way, because If the array is huge, copying will be a problem

I did the following

Ptr2=Ptr1;

This copies the address of Ptr1 to Ptr2 but its elements are not copied..

Please help


memcpy is your friend.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜