views:

195

answers:

3
int x[10],y[10];
x = y;

I am thinking of a simple hack, which would enable me to get this effect.

+11  A: 

You need to use memcpy (or memmove) to transfer a block of memory.

memcpy(x, y, sizeof(x));
KennyTM
+1  A: 

Use memcpy(), or copy it yourself with a for(i=0;i<10;i++) loop

Arthur Kalliokoski
+18  A: 

You can wrap them in structs to use simple assignment:

struct foo { int a[10]; } x, y;
x = y;

But really, just use memcpy.

caf
GCC actually emits a call to `memcpy` with that example.
jleedev