2

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];
Ptr2[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

1 Answer 1

3

memcpy is your friend.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi vanza, Is this the only option?
If you want, you could use a for loop and copy each array element one-by-one. That's a staff member. I'd go with the friend.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.