M
mwebel
Hi!,
im trying to copy the middle part of a dinamycally created char* string
with memcopy but all i get is rubbish...
I understand, that malloc can allocate memory wherever it wants and it
does not have to be in one piece... but how do i access higher parts of
the allocated memory?
lets say source contains "helloworld" and i only want to have "llowo"
in destination... what do i do?
char* destination=malloc(5);
char* source=malloc(8);
[.....]
memcpy(destination, source +3 ,5);
this line copies whatever.... and writing source[3] does not work
either... a hint would be nice...
thanks for any help!
im trying to copy the middle part of a dinamycally created char* string
with memcopy but all i get is rubbish...
I understand, that malloc can allocate memory wherever it wants and it
does not have to be in one piece... but how do i access higher parts of
the allocated memory?
lets say source contains "helloworld" and i only want to have "llowo"
in destination... what do i do?
char* destination=malloc(5);
char* source=malloc(8);
[.....]
memcpy(destination, source +3 ,5);
this line copies whatever.... and writing source[3] does not work
either... a hint would be nice...
thanks for any help!