void main(void)
{
unsigned int a,b,c,d; //這個(gè)定義會(huì)在整個(gè)main函數(shù)中?
SCON = 0x50; //串口方式1,允許接收
TMOD = 0x20; //定時(shí)器1定時(shí)方式2
TH1 = 0xE8; //11.0592MHz 1200波特率
TL1 = 0xE8;
TI = 1;
TR1 = 1; //啟動(dòng)定時(shí)器
a = 5;
b = 6;
c = 7;
d = 8; //這會(huì)在整個(gè)函數(shù)有效
printf("0: %d,%d,%d,%d\n",a,b,c,d);
{ //復(fù)合語(yǔ)句1
unsigned int a,e; //只在復(fù)合語(yǔ)句1中有效
a = 10,e = 100;
printf("1: %d,%d,%d,%d,%d\n",a,b,c,d,e);
{ //復(fù)合語(yǔ)句2
unsigned int b,f; //只在復(fù)合語(yǔ)句2中有效
b = 11,f = 200;
printf("2: %d,%d,%d,%d,%d,%d\n",a,b,c,d,e,f);
}//復(fù)合語(yǔ)句2結(jié)束
printf("1: %d,%d,%d,%d,%d\n",a,b,c,d,e);
}//復(fù)合語(yǔ)句1結(jié)束
printf("0: %d,%d,%d,%d\n",a,b,c,d);
while(1);
}
運(yùn)行結(jié)果:
0:5,6,7,8
1: 10,6,7,8,100
2: 10,11,7,8,100,200
1: 10,6,7,8,100
0:5,6,7,8
結(jié)合以上的說(shuō)明想想為何結(jié)果會(huì)是這樣。
示例程序下載