有关二维字符串数组修改问题
我编写的一段程序中,本来根据按键值修改字符串数组的值,但是在实际操作中出现了,显示修改后,重新修改,数组还是原来的,不知怎么回事#include <reg51.h>
#include <stdio.h>
#include <string.h>
#define uchar unsigned char
#define uint unsigned int
………………………………
//显示
uchar code tab1[]="0.0";
uchar code tab2[]="F-C-P";
/*控制参数*/
uchar code str1[9][4]={"P01:","A01:","P02:","A02:","t01:","t02:","t03:","t04:","L:"};
uchar array1[9][5]={"00180","00000","250.5","003.0","00008","00000","00001","00008","001.5"};
s1[]={0,0,0,0,0};
………………………………
//控制参数设定子程序
int check(uchar p[][5])
{
uchar x,y,z;
int a;
for(x=0;x<9;)//修改控参数据
{
write_control(0x80);
for(y=0;y<4;y++)
{
write_date(str1[x][y]);
}
for(z=0;z<5;z++)
{
s1[z]=p[x][z]-48;
}
if(x==2||x==3||x==8)
a=s1[0]*1000+s1[1]*100+s1[2]*10+s1[4];
else
a=s1[0]*0+s1[1]*1000+s1[2]*100+s1[3]*10+s1[4];
if(UP==0)
{
delay(120);
if(UP==0)
{
a++;
if(x==2||x==3||x==8)
{
p[x][0]=a/1000+48;
p[x][1]=a%1000/100+48;
p[x][2]=a%100/10+48;
p[x][3]=46;
p[x][4]=a%10+48;
}
else
{
p[x][0]=48;
p[x][1]=a/1000+48;
p[x][2]=a%1000/100+48;
p[x][3]=a%100/10+48;
p[x][4]=a%10+48;
}
}
}
if(DOWN==0)
{
delay(120);
if(DOWN==0)
{
a--;
if(a==-1)
a=0;
if(x==2||x==3||x==8)
{
p[x][0]=a/1000+48;
p[x][1]=a%1000/100+48;
p[x][2]=a%100/10+48;
p[x][3]=46;
p[x][4]=a%10+48;
}
else
{
p[x][0]=48;
p[x][1]=a/1000+48;
p[x][2]=a%1000/100+48;
p[x][3]=a%100/10+48;
p[x][4]=a%10+48;
}
}
}
write_control(0x80+0x40);
for(y=0;y<5;y++)
{
write_date(p[x][y]);
}
if(Pgm==0)
{
delay(120);
if(Pgm==0)
x++;
}
}
return x;
}
void main()
{
……………………………………
write_control(0x01);
while(c==1&&d!=9)
{
d=check(array1);
}
……………………………………
}
我编写的一段程序中,本来根据按键值修改字符串数组的值,但是在实际操作中出现了,显示修改后,重新修改,数组还是原来的,不知怎么回事
#include <reg51.h>
#include <stdio.h>
#include <string.h>
#define uchar unsigned char
#define uint unsigned int
………………………………
//显示
uchar code tab1[]="0.0";
uchar code tab2[]="F-C-P";
/*控制参数*/
uchar code str1[9][4]={"P01:","A01:","P02:","A02:","t01:","t02:","t03:","t04:","L:"};
uchar array1[9][5]={"00180","00000","250.5","003.0","00008","00000","00001","00008","001.5"};
s1[]={0,0,0,0,0};
………………………………
//控制参数设定子程序
int check(uchar p[][5])
{
uchar x,y,z;
int a;
for(x=0;x<9;)//修改控参数据
{
write_control(0x80);
for(y=0;y<4;y++)
{
write_date(str1[x][y]);
}
for(z=0;z<5;z++)
{
s1[z]=p[x][z]-48;
}
if(x==2||x==3||x==8)
a=s1[0]*1000+s1[1]*100+s1[2]*10+s1[4];
else
a=s1[0]*0+s1[1]*1000+s1[2]*100+s1[3]*10+s1[4];
if(UP==0)
{
delay(120);
if(UP==0)
{
a++;
if(x==2||x==3||x==8)
{
p[x][0]=a/1000+48;
p[x][1]=a%1000/100+48;
p[x][2]=a%100/10+48;
p[x][3]=46;
p[x][4]=a%10+48;
}
else
{
p[x][0]=48;
p[x][1]=a/1000+48;
p[x][2]=a%1000/100+48;
p[x][3]=a%100/10+48;
p[x][4]=a%10+48;
}
}
}
if(DOWN==0)
{
delay(120);
if(DOWN==0)
{
a--;
if(a==-1)
a=0;
if(x==2||x==3||x==8)
{
p[x][0]=a/1000+48;
p[x][1]=a%1000/100+48;
p[x][2]=a%100/10+48;
p[x][3]=46;
p[x][4]=a%10+48;
}
else
{
p[x][0]=48;
p[x][1]=a/1000+48;
p[x][2]=a%1000/100+48;
p[x][3]=a%100/10+48;
p[x][4]=a%10+48;
}
}
}
write_control(0x80+0x40);
for(y=0;y<5;y++)
{
write_date(p[x][y]);
}
if(Pgm==0)
{
delay(120);
if(Pgm==0)
x++;
}
}
return x;
}
void main()
{
……………………………………
write_control(0x01);
while(c==1&&d!=9)
{
d=check(array1);
}
……………………………………
}