views:

78

answers:

2

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.

+5  A: 

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.

jalf
+3  A: 

Yes, they dont have to.

int test = 3;
char dest[sizeof(int)];

memcpy(&dest[0], &test, sizeof(int));

Is valid c(++).

VDVLeon