By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,234 Members | 1,889 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,234 IT Pros & Developers. It's quick & easy.

copying a 2-dimension array into another

P: n/a
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[i][j]=arr[i][j];
But, How could I make it also with memcpy ??? Or more simple wih another
function ?

Tnx
Johnny
Jun 18 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
johnny <a@a.com> writes:
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[i][j]=arr[i][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.

--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
Jun 18 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.