All pastes #616906 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-07-12 22:21 UTC
rendered paste body
#include <stdio.h>

int
main(void) {
    union {
        unsigned char fbyte;
        struct {
            unsigned int _8 : 1;
            unsigned int _7 : 1;
            unsigned int _6 : 1;
            unsigned int _5 : 1;
            unsigned int _4 : 1;
            unsigned int _3 : 1;
            unsigned int _2 : 1;
            unsigned int _1 : 1;
        } bits;
    } byte;
    
    byte.fbyte = 'i';
    printf("fbyte: %c\n", byte.fbyte);
    printf("bits: %u%u%u%u%u%u%u%u\n", byte.bits._1, byte.bits._2, byte.bits._3, byte.bits._4, byte.bits._5, 
    byte.bits._6, byte.bits._7, byte.bits._8);
    return getchar();
}