memcpy(), what should the value of the size parameter be?
- by Tomas
Hi,
I want to copy an int array to another int array. They use the same define for length so they'll always be of the same length.
What are the pros/cons of the following two alternatives of the size parameter to memcpy()?
memcpy(dst, src, ARRAY_LENGTH*sizeof(int));
or
memcpy(dst, src, sizeof(dst);
Will the second option always work? Regardless of the content?
One thing that favors the last one is that if the array were to change, it'll be some house-keeping to update the memcpy()'s.
Thanks