// This program uses some special parts of C++ // I have replaced some things in it by /******/. // Use the compiler and test runs to help fix them. #include using namespace std; struct Byte{ //Eight bits maketh a byte, 4bits a nibble. unsigned short int b0:1; unsigned short int b1:1; unsigned short int b2:1; unsigned short int b3:1; unsigned short int b4:1; unsigned short int b5:1; unsigned short int b6:1; unsigned short int b7:1; }; union BytesAndPieces{// its a Byte, its a char, it's.... a Union. char c; Byte byte; }; int main() { char c='a'; do{ // do it with c='a', 'b', 'c', ... ,'z' BytesAndPieces w; w.c = c; cout << w.c << " "; for(int j=7; j>=0; j--) { switch(j) { case 7: cout << w.byte.b7; break; case 6: cout << w.byte.b6; break; case 5: cout << w.byte.b5; break; case 4: cout << w.byte.b4; break; case 3: cout << w.byte.b3; break; case 2: cout << w.byte.b2; break; case 1: cout << w.byte.b1; break; case 0: cout << w.byte.b0; break; } } cout << "\t"; for( int j = 7; j>=0; j--) { cout << ((1 & (c>>j)) ? '1' : '.' );// do a bitwise-and with 1 and shifted c. } cout << endl; c++; }while(c <= 'z'); }