Structure within union and bit field
        Posted  
        
            by 
                java
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by java
        
        
        
        Published on 2012-10-21T16:10:33Z
        Indexed on 
            2012/10/21
            17:01 UTC
        
        
        Read the original article
        Hit count: 191
        
#include <stdio.h>
union u
{
    struct st
    {
        int i : 4;
        int j : 4;
        int k : 4;
        int l;
    } st;
    int i;
 } u;
int main()
{
    u.i = 100;
      printf("%d, %d, %d", u.i, u.st.i, u.st.l);
}
I'm trying to figure out the output of program. The first outputs u.i = 100 but I can't understand the output for u.st.i and u.st.l. Please also explain bit fields.
© Stack Overflow or respective owner