我想获得z_Data
的第48个字符的第6位{
char c = pPkt->z_Data[47]; // this z_Data is a char buffer
std::cout<<(c>>3)&1<<std::endl;
std::cout<<(c>>4)&1<<std::endl;
std::cout<<(c>>5)&1<<std::endl;
}
答案 0 :(得分:8)
<<
的优先级高于&
的优先级,因此您需要:
std::cout << ((c >> 3) & 1) << std::endl;
std::cout << ((c >> 4) & 1) << std::endl;
std::cout << ((c >> 5) & 1) << std::endl;