copying a 2-dimension array into another

J

johnny

Hi,. I have an arry like:

float arr[4][5];

I want to copy the content of each element in arr to this array

float target[4][5];

I know if I make this it will work:

for(i=0;i<4;i++)
for(j=0;j<5;j++)
target[j]=arr[j];


But, How could I make it also with memcpy ??? Or more simple wih another
function ?

Tnx
Johnny
 
N

Nelu

johnny said:
Hi,. I have an arry like:

float arr[4][5];

I want to copy the content of each element in arr to this array

float target[4][5];

I know if I make this it will work:

for(i=0;i<4;i++)
for(j=0;j<5;j++)
target[j]=arr[j];


But, How could I make it also with memcpy ??? Or more simple wih
another function ?


include <string.h>

and try: memcpy(target,arr,sizeof(arr));
If arr is a pointer as opposed to array this won't work unless you
make some changes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,786
Messages
2,569,625
Members
45,320
Latest member
icelord

Latest Threads

Top