| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4206 人关注过本帖
标题:有关二维字符串数组修改问题
只看楼主 加入收藏
淡汐蓝
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-5-27
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
有关二维字符串数组修改问题
我编写的一段程序中,本来根据按键值修改字符串数组的值,但是在实际操作中出现了,显示修改后,重新修改,数组还是原来的,不知怎么回事
#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);
    }
……………………………………
}
搜索更多相关主题的帖子: 字符串 include 
2013-05-27 11:47
小xiong
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
帖 子:388
专家分:1722
注 册:2013-2-8
收藏
得分:20 
你这个数组是不能修改的,它放在code区,
2013-05-30 17:18
快速回复:有关二维字符串数组修改问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029127 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved