I got an array of char with 8 positions(char data[8];), this array has an unsigned long long int value on it (8 bytes of size)... data[0] has the first byte of the long long int, data[1] has the second and so on. My question is how to put that value again on an unsigned long long variable?
I've tried shifts but the value wasn't equal de original value, how can i do this without changing the original array...
The order of the bytes is little endian the normal order of variables (from Hight bit to low bit)
Here is a code that prints a different value than expected.
char vec[8]={0,0,0,0,0,0,0,1};
unsigned long long value = *((unsigned long long*) vec);
std::cout<<value;
return 0;
The result should be one but instead is 72057594037927936. Thank you for your patience.