Bit level allocation should be on unsigned integrals. So use unsigned
ints in the structure.

[EMAIL PROTECTED]:~/programs/c> cat test.c
#include<stdio.h>

int main()
{
        struct value
    {
                unsigned int bit1 : 2;
            unsigned int bit2 : 2;
        };
        struct value v1={2,2};

        printf("%d %d\n",v1.bit1,v1.bit2);
        return 0;
}

[EMAIL PROTECTED]:~/programs/c> cc test.c
[EMAIL PROTECTED]:~/programs/c> ./a.out
2 2


--- In [email protected], The Devil <[EMAIL PROTECTED]>
wrote:
>
> hi can ay one solve this problem please .
>    tell me what does this program print & why ??
>    
>   #include<stdio.h>
> #include<conio.h>
> void main()
> {
>  clrscr();
>  struct value
>  {
>   int bit1 : 2;
>   int bit2 : 2;
>  };
>  struct value v1={2,2};
>  printf("%d %d",v1.bit1,v1.bit2);
>  getch();
> }
>    
>    
> 
>               
> ---------------------------------
> New Yahoo! Messenger with Voice. Call regular phones from your PC
and save big.
> 
> [Non-text portions of this message have been removed]
>







------------------------ Yahoo! Groups Sponsor --------------------~--> 
Everything you need is one click away.  Make Yahoo! your home page now.
http://us.click.yahoo.com/AHchtC/4FxNAA/yQLSAA/EbFolB/TM
--------------------------------------------------------------------~-> 

>-----------------------------------------~-~>
CHECK THE ARCHIVE BEFORE POSTING!!!! Archive is available at 
http://www.eScribe.com/software/C-Paradise/

>------------------------------------------_->


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/C-Paradise/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to