U
urocrane
I've been working around a sample program thats "suppose" to work,
according to Herbert Schildt-but it doesn't... I'm getting a
redefinition error from struct byte. anyone know whats wrong and how
to fixit? and i need some indepth tutorials about bitwise operators
and bitfield.
struct byte
{
unsigned a : 1;
unsigned b : 1;
//... all the way to unsigned h : 1;
};
union bits
{
char ch;
byte bit;
} ascii; //this program displays the ascii code in binary for
characters
void disp_bits(bits b); /*contains code like if(b.bit.h) cout<<"1 "l;
else cout<<"0 "; */
int main()
{
do
{
cin>>ascii.ch;
cout<<": ";
disp_bits(ascii);
}while(ascii.ch!='q');
return 0;
}
according to Herbert Schildt-but it doesn't... I'm getting a
redefinition error from struct byte. anyone know whats wrong and how
to fixit? and i need some indepth tutorials about bitwise operators
and bitfield.
struct byte
{
unsigned a : 1;
unsigned b : 1;
//... all the way to unsigned h : 1;
};
union bits
{
char ch;
byte bit;
} ascii; //this program displays the ascii code in binary for
characters
void disp_bits(bits b); /*contains code like if(b.bit.h) cout<<"1 "l;
else cout<<"0 "; */
int main()
{
do
{
cin>>ascii.ch;
cout<<": ";
disp_bits(ascii);
}while(ascii.ch!='q');
return 0;
}