Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Bit Field Problem (http://www.go4expert.com/forums/bit-field-problem-t11345/)

shyam_oec 15Jun2008 01:14

Bit Field Problem
 
Consider the declaration:



main()
{
struct num
{
a:1;
};

struct num A;
A.a=0;
printf("%d",A.a);
}



It gave output 0,that's fine.

Now consider the declaration :

main()
{

a:1;
a=0;
printf("%d",a);
}


It gave error that code a:1 has no effect and that a is undefined.

with reference to the above i am Bit Confused about structure!!!That what structure has done in the first code,and why error in the absence of structure occured???

shabbir 15Jun2008 08:40

Re: Bit Field Problem
 
I think the error should occur for first one as well but a:1 cannot be a variable declaration or at least I don't know if such things can be defined.


All times are GMT +5.5. The time now is 05:54.