Basic question about endianness

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

  1. pdk123

    pdk123 New Member

    Joined:
    Aug 28, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hello,

    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{
    public:
    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

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice