Hello,
I made the following code to convert known datatypes to bytes:
template <class T>
void convertToByte(const T *t, PBYTE pbArray)
{
DWORD dwSize = sizeof(T);
memset(pbArray, 0, dwSize);
memcpy_s(pbArray, dwSize, reinterpret_cast<LPCVOID>(t), dwSize);
}
But i was wondering how i'd go about it without passing a datatype into the array. i'd like to create a function that i could just define a size and value and convert it to bytes.
So when i pass DWORD (unsigned int) which is 4 bytes holding a value of 3234.
Becomes;
1 Byte - 162
1 Byte - 12
1 Byte - 0
1 Byte - 0
So i'm wondering how 162 and 12 are converted to 3234?
Thanks guys.