I have an array and also a buffer of char*
I have memcpy from buffer into the array, is this ok or should i memcpy into another buffer of char* and free it when done?
I dont have to free an array after a memcpy as not technically a pointer.
Printable View
I have an array and also a buffer of char*
I have memcpy from buffer into the array, is this ok or should i memcpy into another buffer of char* and free it when done?
I dont have to free an array after a memcpy as not technically a pointer.
No problem. The only thing you need to worry about is if your array is big enough to hold all the data you're copying.
Grand cheers for that, just couldnt remember if it was ok or not. Size is grand as all taken care of!
Thanks
The only thing to watch out for with memcpy() is to make sure that source and destination do NOT overlap.
If they're two separate buffers, then it's not a problem.
But if you're trying to move the tail of a buffer to the head (so you can add more data), then memcpy() is the wrong thing to use. Use memmove() in this case.