为什么c51程序中总会出现 syntax error near 'int'
#include"reg51.h"
#include"string.h"
#include"intrins.h"
#include"absacc.h"
#include"stdlib.h"
#include"math.h"
typedef unsigned char uchar;
sbit BEEP=P1^1; //蜂鸣器
sbit KEY=P1^2;//LED
uchar table[17]={0x28,0x7e,0xa2,0x62,0x74,0x61,0x21,0x7a,0x20,0x60,0x30,0x25,0xa9,0x26,0xa1,0xb1};
uchar disbuff;//显示缓存
uchar key;
void display(unsigned char disp);
void beep();
void keyscan(void);
void keydown(void);
void delay0(unsigned char x);
void delay(unsigned char x);
void main (void)
{
P0=0xff;
P1=0xff;
P2=0xff;
disbuff=0xbf;
while(1)
{
keyscan();
keydown();
display(disbuff);
delay(2);
}
}
void keyscan(void)
{
P2=0xFE;
key=P2;
unsigned int i;//总是在这里出错
for (i=0;i<4;i++)
{ if(P2<key)
{
if(P2.6==0)
key=i+i*3+2;
else if(P2.5==0)
key=i+1+i*3;
else key=i+i*3;
break;
}
P2=P2<<1;
}
disbuff=table[key];
}
| | |
|