奇怪?为什么?
对上面的程序进行调试,测试其中的部分程序就发现问题。
程序如下:
#include <stdio.h>
#include <reg51.h>
main(){
float pot_1[]={99.9,88.8,77.7,66.6,0};
float pot_2[]={11.1,22.2,33.3,44.4,55.5,99.9,88.8,77.7,66.6,0};
SCON=0x52;
TMOD=0x20;
TCON=0x69;
TH1=0x0F3;
printf("the average of A is %6.2f\n",pot_1[0]);
printf("the average of B is %6.2f\n",pot_2[0]);
}
输出就不出来。而屏蔽两条语句后,如下所示:
#include <stdio.h>
#include <reg51.h>
main(){
float pot_1[]={99.9,88.8,77.7,66.6,0};
//float pot_2[]={11.1,22.2,33.3,44.4,55.5,99.9,88.8,77.7,66.6,0};
SCON=0x52;
TMOD=0x20;
TCON=0x69;
TH1=0x0F3;
printf("the average of A is %6.2f\n",pot_1[0]);
//printf("the average of B is %6.2f\n",pot_2[0]);
}
输出结果就对了。
奇怪?为什么?
发表时间:2003年9月11日9:37:12