Copy 6 byte array to long long integer variable
问题 I have read from memory a 6 byte unsigned char array. The endianess is Big Endian here. Now I want to assign the value that is stored in the array to an integer variable. I assume this has to be long long since it must contain up to 6 bytes. At the moment I am assigning it this way: unsigned char aFoo[6]; long long nBar; // read values to aFoo[]... // aFoo[0]: 0x00 // aFoo[1]: 0x00 // aFoo[2]: 0x00 // aFoo[3]: 0x00 // aFoo[4]: 0x26 // aFoo[5]: 0x8e nBar = (aFoo[0] << 64) + (aFoo[1] << 32) +