标题: 帮忙看看这个程序的错误 [打印本页]

作者: 繁星星    时间: 2015-7-5 17:10
标题: 帮忙看看这个程序的错误
#include<reg51.h>
#include<intrins.h>

void Delay();

sbit P2_0=P2^0;
sbit P2_1=P2^1;
sbit P2_2=P2^2;
sbit P2_3=P2^3;
sbit P2_4=P2^4;
sbit P2_5=P2^5;
sbit P2_6=P2^6;
sbit P2_7=P2^7;

void main();
{
        P1=0x00;
        Delay();
        P1=0xFF;
        Delay();
        P1=0x00;
        Delay();
        P1=0xFF;
        Delay();

while(1)
        {
                if(P2==0xFE)
                {
                        P1=0xC0;
                }
                else if(P2==0xFD)
                {
                        P1=0xF9;
                }
                else if(P2==0xFB)
                {
                        P1=0xA4;
                }                          
                else if(P2==0xF7)
                {
                        P1=0xB0;
                }                          
                else if(P2==0xEF)
                {
                        P1=0x99;
                }                          
                else if(P2==0xDF)
                {
                        P1=0x92;
                }                          
                else if(P2==0xBF)
                {
                        P1=0x82;
                }
                else if(P2==0x7F)
                {
                        P1=0xF8;
                }               
                else if(P2==0xFC)
                {
                        P1=0x80;
                }               
                else if(P2==0xFA)
                {
                        P1=0x90;
                }                         
                else if(P2==0xF6)
                {
                        P1=0x88;
                }                         
                else if(P2==0xEE)
                {
                        P1=0x83;
                }                         
                else if(P2==0xDE)
                {
                        P1=0xC6;
                }               
                else if(P2==0xBE)
                {
                        P1=0xA1;
                }                       
                else if(P2==0x7E)
                {
                        P1=0x86;
                }               
                else
                {
                        P1=0xFF;
                }
        }
}

void Delay();
{
        int i;
        for(i=0;i<1000;i++)
        {
                _nop_();
        }
}                   
这个是程序就是一个简单的键盘输入数码管显示的程序 ,但是有很多错误,我找不出来哪里错还是个新手,希望大家帮忙看看。图片就是错误提示,还有很多,但全是error c141 c279 c231


QQ图片20150705170903.png (5.33 KB, 下载次数: 121)

QQ图片20150705170903.png

作者: 繁星星    时间: 2015-7-5 17:19
请大家帮个忙了。没人看嘛都?
作者: 海哥沧海一笑    时间: 2015-7-5 17:33
#include<reg51.h>
#include<intrins.h>

void Delay();

sbit P2_0=P2^0;
sbit P2_1=P2^1;
sbit P2_2=P2^2;
sbit P2_3=P2^3;
sbit P2_4=P2^4;
sbit P2_5=P2^5;
sbit P2_6=P2^6;
sbit P2_7=P2^7;

void main()
{
P1=0x00;
  Delay();
  P1=0xFF;
  Delay();
  P1=0x00;
            Delay();
            P1=0xFF;
            Delay();

while(1)
            {
                        if(P2==0xFE)
                        {
                                    P1=0xC0;
                        }
                        else if(P2==0xFD)
                        {
                                    P1=0xF9;
                        }
                        else if(P2==0xFB)
                        {
                                    P1=0xA4;
                        }                                         
                        else if(P2==0xF7)
                        {
                                    P1=0xB0;
                        }                                       
                        else if(P2==0xEF)
                        {
                                    P1=0x99;
                        }                                       
                        else if(P2==0xDF)
                        {
                                    P1=0x92;
                        }                                       
                        else if(P2==0xBF)
                        {
                                    P1=0x82;
                        }
                        else if(P2==0x7F)
                        {
                                    P1=0xF8;
                        }                        
                        else if(P2==0xFC)
                        {
                                    P1=0x80;
                        }                        
                        else if(P2==0xFA)
                        {
                                    P1=0x90;
                        }                                       
                        else if(P2==0xF6)
                        {
                                    P1=0x88;
                        }                                       
                        else if(P2==0xEE)
                        {
                                    P1=0x83;
                        }                                       
                        else if(P2==0xDE)
                        {
                                    P1=0xC6;
                        }                        
                        else if(P2==0xBE)
                        {
                                    P1=0xA1;
                        }                                    
                        else if(P2==0x7E)
                        {
                                    P1=0x86;
                        }                        
                        else
                        {
                                    P1=0xFF;
                        }
            }
}

void Delay()
{
            int i;
            for(i=0;i<1000;i++)
            {
                        _nop_();
            }
}     
作者: 繁星星    时间: 2015-7-5 17:35
于帅 发表于 2015-7-5 17:20
却黑笔

啊?什么意思啊?能不能说清楚一点我不是太懂
作者: 繁星星    时间: 2015-7-5 18:39
海哥沧海一笑 发表于 2015-7-5 17:33
#include
#include

谢谢了,真是太粗心在函数那多加了两个引号。以后有经验了
作者: 繁星星    时间: 2015-7-5 18:40
于帅 发表于 2015-7-5 17:20
却黑笔

谢谢了!!!终于找着错了
作者: 繁星星    时间: 2015-7-5 18:41
海哥沧海一笑 发表于 2015-7-5 17:33
#include
#include

谢谢,找着错了。
作者: gaozhaohong    时间: 2015-7-5 20:32
其实就是在主程序后面和延时子程序后面多了两个分号,去掉就正常了。
作者: 大虫子666    时间: 2015-7-5 22:55
我去 感觉号复杂                           
作者: 尘嚣下的逃亡    时间: 2015-7-6 13:06
来晚了




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1