i don't know where is the problem i'm assigning the address to other 2 dimensional array. Please help me to fix this problem
int main()
{
int a[3][2];
int b[2]={0,1};
a[2]=b;
return 0;
}
prog.cpp:8:9: error: invalid array assignment
You can't copy an array using =
. Neither can you assign an array's address; x = y;
doesn't work either when x
and y
have types char[1]
for example. To copy the contents of b
to a[2]
, use memcpy
:
memcpy(a[2], b, sizeof(a[2]));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With