I have a struct with same type members in it. I am trying to convert it into uint8_t
type. I am able to do that but cannot see the output please tell me where I am going wrong. Also I know there are another ways to do it? I am trying to do it this way because I want to get use to static_cast
and reinterpret_cast
.
Code is below:
int main()
{
struct xs{
bool x :1 ;
bool y :1;
bool z :1;
uint8_t num :5;
} zs;
uint8_t* P = static_cast<uint8_t*>(static_cast<void*>(&zs));
cout << *P << endl;
return 0;
}