What are you trying to do? If you are trying to serialize a structure in order to save it to a file or pass it in a message, you are better off using a tool designed for this, like pushing :: serialization .
If you just want an array of bytes, you could reinterpret_cast<char*> , as others have mentioned, or do:
MyStruct s; char [] buffer = new char[sizeof(s)]; memcpy(&buffer, &s, sizeof(s));
David
source share