1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Basic question about endianness

Discussion in 'C++' started by pdk123, Aug 28, 2010.

  1. pdk123

    pdk123 New Member

    Aug 28, 2010
    Likes Received:
    Trophy Points:

    Is the endianess can be for the nibble boundaries ? Because i have defined a class, and try to access the array with a pointer of class type.

    typedef unsigned char uint8;

    class A{
    uint8 a:4;
    uint8 b:4;

    int _tmain(int argc, _TCHAR* argv[])
    uint8 temp = 0xfa;

    A * ptr_a;

    ptr_a = (A *) &temp;

    printf("%x", ptr_a->a );


    To my surprise, a is 0x0a and not '0x0f' !. Any comments on this, will be very helpful, as i have a very big structure with access to nibble boundaries, will make it more complex for me to determine which bit goes where !!!

Share This Page