char c = *(char*)pByte;
short shrt = *(short*)(pByte+1);long lng = *(long*)(pByte+3);float flt = *(float*)(pByte+7);string str = (char*)(pByte+11);
JohnEx:
You are not converting char to float; rather you are interpreting a sequence of 4 bytes as a float. Not the same thing at all. There is no need to first interpret the sequence of bytes as a string, or to use memcpy.You have a BYTE stream, say pByte (a BYTE*), and the float value is at positions 7 through 10float f = *(float*)(pByte+7);Similarly for the other valueschar c = *(char*)pByte;short shrt = *(short*)(pByte+1);long lng = *(long*)(pByte+3);float flt = *(float*)(pByte+7);string str = (char*)(pByte+11);(assuming the string part is correctly null-terminated). I would write a single function to write these values into a struct, so the rest of the code can be clean.