I have two arrays, a and b, both of length x bytes. I need to use memcpy to copy the memory from a to b. What is the correct syntax to use, since memcpy takes in two void* as its argument? Is it:
memcpy(&a[0], &b[0], x);
I have two arrays, a and b, both of length x bytes. I need to use memcpy to copy the memory from a to b. What is the correct syntax to use, since memcpy takes in two void* as its argument? Is it:
memcpy(&a[0], &b[0], x);
To copy x bytes from a to b, you'd say:
memcpy(b, a, x);
memcpy() takes the destination first, then the source.
Array names evaluate to the array address when used as parameters, and void * parameters will accept any pointer you throw at them.
memcpy(&b[0], &a[0], x);
would be equivalent, but needlessly verbose.