Reputation: 10790
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.
Upvotes: 1
Views: 289
Reputation: 248199
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.
Upvotes: 5
Reputation: 1394
Yes, they dont have to.
int test = 3;
char dest[sizeof(int)];
memcpy(&dest[0], &test, sizeof(int));
Is valid c(++).
Upvotes: 3