#include <iostream>
using namespace std;
int getBit8(int *pInt32, int index) {
return (*pInt32 >> (index * 8)) & (0xff >> sizeof(int));
}
int getBit8x(int32_t *pInt32, int index) {
return (*pInt32 >> (index * 8)) & (0xff >> 32);
}
int main() {
int a[] = { 0, 1, 2, 3 };
getBit8(a, 2);
getBit8x(a, 1);
printf("%d %d %d %d", a[0], a[1], a[2], a[3]);
}
//http://pt.stackoverflow.com/q/190575/101
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IGdldEJpdDgoaW50ICpwSW50MzIsIGludCBpbmRleCkgewogICAgcmV0dXJuICgqcEludDMyID4+IChpbmRleCAqIDgpKSAmICgweGZmID4+IHNpemVvZihpbnQpKTsKfQoKaW50IGdldEJpdDh4KGludDMyX3QgKnBJbnQzMiwgaW50IGluZGV4KSB7CiAgICByZXR1cm4gKCpwSW50MzIgPj4gKGluZGV4ICogOCkpICYgKDB4ZmYgPj4gMzIpOwp9CgppbnQgbWFpbigpIHsKCWludCBhW10gPSB7IDAsIDEsIDIsIDMgfTsKCWdldEJpdDgoYSwgMik7CglnZXRCaXQ4eChhLCAxKTsKCXByaW50ZigiJWQgJWQgJWQgJWQiLCBhWzBdLCBhWzFdLCBhWzJdLCBhWzNdKTsKfQoKLy9odHRwOi8vcHQuc3RhY2tvdmVyZmxvdy5jb20vcS8xOTA1NzUvMTAx