Struct to memoryBlock?


How would one go about appending structs to a memory block.

I’m thinking memcpy would be involved.

Or would this work:

structObj myObj;
//do stuff
MemoryBlock M;
M.append(myObj, sizeof(myObj));

I basically don’t get how a struct relates to plain memory,arrays etc.


If myObj has pointers to anything outside the struct (or even inside), then you can’t memcpy it or append it. You have to serialize it.


So I take that if it doesn’t have any pointers, just plain variables, I can memcpy it?
Fair enough.