高手帮我注释下以下两个程序吧
第一个#define PB(X) printf((X)?"1":"0")
#define UI unsigned int
struct byte
{ UI a0:1;UI a1:1; UI a2:1; UI a3:1; UI a4:1; UI a5:1; UI a6;
UI a7;};
union bits{char ch;struct byte bit;};
void decode(union bits c);
main()
{char c; union bit asc;
for(c='A';c<'C';c++)
{asc.ch=c;
printf("%o:",c);
decode(asc);
}
}
void decode(union bits b)
{PB(b.bit.a7);PB(b.bit.a6);PB(b.bit.a5);PB(b.bit.a4);PB(b.bit.a3);PB(b.bit.a2);PB(b.bit.a1);PB(b.bit.a1);
printf("\n");
}
第二个
struct bit
{unsigned bund_bit:2;
unsigned char_bit:2;
unsigned pari_bit:1;
unsigned even_bit:1;
unsigned stop_bit:2;
unsigned dummybit:8;
};
main()
{unsigned int *pmodword;
struct bit mod;
mod.bund_bit=input("bund bit(0-3)");
mod.char_bit=input("bund bit(0-3)");
mod.pari_bit=input("bund bit(0,1)");
mod.even_bit=input("bund bit(0,1)");
mod.stop_bit=input("bund bit(0-3)");
mod.dummybit=0;
pmodword=(unsigned int *)&mod;
printf(\n The mode word is %x\n",*pmodword);
}
input(s)
char *s;
{int bits;
printf("Enter %s:",s);
scanf("%d",&bits);
return(bits);
}
越详细越好啊
[ 本帖最后由 miracleyyf 于 2010-3-24 16:44 编辑 ]