标题:
求助exp2.c(23): error C141: syntax error near '=='
[打印本页]
作者:
处处都是error
时间:
2020-6-21 21:51
标题:
求助exp2.c(23): error C141: syntax error near '=='
#include <REGX51.H>
#define uint unsigned int
#define uchar unsigned char
sbit Buzzer=P3^7;
sbit Led=P2^0;
void delay(int ms);
void delay(int ms)//延时函数
{
unsigned int i,j;
while(ms--)
{
for(i=0;i<ms;i++)
{
for(j=0;j<110;j++)
}
}
}
unsigned char key()
{
unsigned char count=0;
if(P1&0x0f)
==
0x0f
)
{
delay(5);
if(P1^4==0) count=1;
}
else
{
count=0;
}
return count;
}
void main()
{
unsigned char mm;
while(1)
{
Led=0;//关掉led灯
Buzzer=0;
mm=key();
if(mm !=0)//确认按键是否按下
{
Led=1;
delay(1000);
Led=0;
delay(1000);
}
if(mm!=0)//确认按键是否按下
{
Buzzer=1;
delay(500);
Buzzer=0;
delay(500);
}
}
}
以上是代码,红色的是有错的地方
下面是错误,实在不懂为啥会错
exp2.c(16): error C141: syntax error near '}'
exp2.c(22): error C141: syntax error near '=='
exp2.c(22): error C141: syntax error near ')'
exp2.c(30): error C141: syntax error near 'else'
作者:
LLN111111
时间:
2020-6-21 22:10
delay函数的第二个for缺少;。然后第二个错误那里括号不匹配,
作者:
1224527279
时间:
2020-6-22 09:02
if(P1&0x0f)==0x0f)
{
delay(5);
if(P1^4==0) count=1;
}
else
{
count=0;
}
return count;
if那里括号缺少个左侧小括号,改为
if((P1&0x0f)==0x0f)
{
delay(5);
if(P1^4==0) count=1;
}
else
{
count=0;
}
return count;
作者:
1224527279
时间:
2020-6-22 09:03
void delay(int ms)//延时函数
{
unsigned int i,j;
while(ms--)
{
for(i=0;i<ms;i++)
{
for(j=0;j<110;j++)
}
}
}
这里改为
void delay(int ms)//延时函数
{
unsigned int i,j;
while(ms--)
{
for(i=0;i<ms;i++)
{
for(j=0;j<110;j++);
}
}
}
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1