I have a 3 dimensional array int32_t x[1024][4][256]
. I need to copy all the elements of the array to another array of same type and size int32_t y[1024][4][256]
.
Can i use memcpy(y, x, sizeof(x));
?
after that can I access the elements of array y
same as that of x
?
can i use
memcpy(y, x, sizeof(x))
?
Yes.
after that can I access the elements of array
y
same as that ofx
?
Yes.
Note that this approach breaks down if you allocate the array dynamically (e.g. using malloc()
). If you do that, sizeof()
will no longer give you the size of the array (it will give the size of the pointer), and you'll have to keep track of the array dimensions yourself.
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