does memcpy params have to be of the same type?
I was reading that memcpy takes the number of bytes from a source location and adds it to a destination location. Does this mean that memcpy could possibly 开发者_开发技巧change datatype entirely ??
memcpy(DoubleOne, CharTwo, strlen(CharTwo));
considering that both values are empty still.
Yes, memcpy
doesn't care about the types. (It converts both its parameters to void pointers anyway)
It doesn't "change datatype" as much as it just writes char
data into a double
array (in your case) and hopes it makes sense.
Yes, they dont have to.
int test = 3;
char dest[sizeof(int)];
memcpy(&dest[0], &test, sizeof(int));
Is valid c(++).
精彩评论