struct abc
{
int a:3;
int b:3;
int c:2;
}
Defines (note: the missing semicolon is a syntax error) three
bit fields in the struct
abc
. All share the same type, namely
signed integer,
a
and
b
are three bits long (they may hold the values
{-4,-3,-2,-1,0,1,2,3}
) while
c
is two bits long (it may hold the values
{-2,-1,0,1}
).
struct abc a=(2,3,4)
The above line (again, the missing semicolon is a syntax error) initializes the instance
a
of the struct
abc
this way:
a.a = 2;
a.b = 3;
a.c = 4;
printf(" %d %d %d",a.a,a.b,a.c);
The above line prints the values of the bit fields.
gethc();
I don't know what it is. Do you mean
getch();
instead?