Let’s say I’ve got a unsigned char pointer (uchar* from now on) to the beginning of an array of type T different from uchar. Knowing the size of this array and that it is continuous (created using malloc), is it possible to copy it to another array without knowing the type T? How can I access it byte per byte?
Thanks
You can make a shallow copy of everything with a simple
memcpyormemmove, but you better be sure that the array elements are no class objects that contain any pointers. Or more precisely, make sure they are PODs.