i want to get the 6th bit of 48th character of z_Data
{
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;
}
<<
has a higher precedence than that of &
, so you need:
std::cout << ((c >> 3) & 1) << std::endl;
std::cout << ((c >> 4) & 1) << std::endl;
std::cout << ((c >> 5) & 1) << std::endl;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With