想进行数组判断,一个unsigned char数组stA【6】内有字符型数字2,5,3,4,1,9
一个unsigned int数组stB【6】,还有一个数码管段码已经放在一个code table【】里顺序0-9.
想通过判断stA数组内的数字将对应元素位上的stB数组附上段码的值。
比如stA【1】是字符型数字5,通过判断后stB【1】等于段码table【5】即数码管数字5的段码。
void change()
{
uint i=0;
for(i=0;i>6;i++)
{
if(str[i]== '0')
{stB[i]=table[0];}
if(str[i]== '1')
{stB[i]=table[1];}
if(str[i]== '2')
{stB[i]=table[2];}
if(str[i]== '3')
{stB[i]=table[3];}
if(str[i]== '4')
{stB[i]=table[4];}
if(str[i]== '5')
{stB[i]=table[5];}
if(str[i]== '6')
{stB[i]=table[6];}
if(str[i]== '7')
{stB[i]=table[7];}
if(str[i]== '8')
{stB[i]=table[8];}
if(str[i]== '9')
{stB[i]=table[9];}
}
i=0;
//if(str[5]== '1')
//{stB[5]=table[1];}
//if(str[4]== '3')
//{stB[4]=table[3];}
//if(str[3]== '9')
//{stB[3]=table[9];}
//if(str[2]== '2')
//{stB[2]=table[2];}
//if(str[1]== '3')
//{stB[1]=table[3];}
//if(str[0]== '5')
//{stB[0]=table[5];}
}
void display(unsigned long num)
{
str[0]=(5)+'0';
str[1]=(3)+'0';
str[2]=(2)+'0';
str[3]=(9)+'0';
str[4]=(3)+'0';
str[5]=(1)+'0';
change();
注释的地方却可以正常判断并赋值代码放到循环就无法判断了,数码管直接显示设定的初值123456
那里打错了后面改成小于6还是不成
好吧原来是我另一个调用地方出现了错误,将数组重置了。。。。