unsigned char byte_a, byte_b, byte_c; unsigned char char_1, char_2, char_3, char_4; /* Retrieve byte_a, byte_b and byte_c from the data stream */ byte_a = fgetc(fp); byte_b = fgetc(fp); byte_c = fgetc(fp); /* Map 3 bytes into 4 characters, each between 0 and 63 */ /* see BOXOUT: Trout Mask Replica for more information */ char_1 = (byte_a >> 2) & 0x3f; /* First 6 bits of a */ char_2 = (byte_a << 4) & 0x30; /* Last 2 bits of a */ char_2 |= (byte_b >> 4) & 0x0f; /* First 4 bits of b */ char_3 = (byte_b << 2) & 0x3c; /* Last 4 bits of b */ char_3 |= (byte_c >> 6) & 0x03; /* First 2 bits of c */ char_4 = byte_c & 0x3f; /* Last 6 bits of c */ /* Offset to the 32-95 range */ char_1 += 32; char_2 += 32; char_3 += 32; char_4 += 32;