Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'

Tags:

c++

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;
}
like image 993
Sachyy_J Avatar asked Jul 10 '14 07:07

Sachyy_J


1 Answers

<< 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;
like image 158
Yu Hao Avatar answered Oct 05 '22 16:10

Yu Hao