Bit Field Problem

shyam_oec's Avatar, Join Date: Nov 2007
Contributor
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???
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
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.