2009-08-14, 01:48 PM
Fiel Wrote:I have an "unsigned char* unpackedZlibBlock;" string, but I want to be able to read values from that string (ints, doubles, floats). So let's say that the first four bytes of this string is supposed to be interpreted as an integer. What would be the best way to fetch those four bytes from the string? "strncpy"? "memcpy"?unsigned char* unpackedZlibBlock = getUnpackedZlibBlock();
unsigned char* zlibBlockPos = unpackedZlibBlock;
unsigned int numberOfChinchillas = *((unsigned int *) (zlibBlockPos));
zlibBlockPos += 4;
You can just cast the unsigned char pointer to an unsigned int (or whatever) pointer.

