The basic idea is to treat the buffer as a pointer to DWORD, and dereference it.
However if you read it from a file, it could be a different story. If the file was created on a different type of machine, it could save the bytes in a different order.
It I recall correctly, in most PC, we store a DWORD (for example 0x12345678) like this:
Nice, that works. But I need to write a dword and then a zero-terminated string to the buffer.
The DWORD is easy, the same as reading from it but how do I write a Zstring right after it? (I am using interprocess communication so I'm reading and writing to a byte buffer, if you're curious)
I tried this
1 2
*(DWORD *)writeBuffer = RESPONSECODE;
*(char *)writeBuffer+4 = "This is a test...";