Quick and dirty solution:
int32_t value1 = *(int32_t*)(charArray + 0); int64_t value2 = *(int64_t*)(charArray + 4); int64_t value3 = *(int64_t*)(charArray + 12);
Please note that this may result in improper memory access. So this may not always work.
A more robust solution that does not violate strict anti-aliasing and will not have alignment problems:
int32_t value1; int64_t value2; int64_t value3; memcpy(&value1,charArray + 0,sizeof(int32_t)); memcpy(&value2,charArray + 4,sizeof(int64_t)); memcpy(&value3,charArray + 12,sizeof(int64_t));
source share