Keil 编译中的syntax error near...简单问题求助

direren 2010-05-28 04:32:24
在keil编译器中编译c程序,出现了 syntax error near"]", 程序不复杂,想请教一下是哪错了。多谢。

#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
void delay(uint k);
void delayus(uint k);//延时
void write_LCD_command(uchar command);//命令写入LCD
void write_LCD_data(uchar data_a);//数据写入LCD
void init_1602(void);//初始化LCD
void clear_LCD();//LCD清屏
sbit P1_0=P1^0;
sbit P1_1=P1^1;
sbit P3_3=P3^3;
sbit P3_4=P3^4;
sbit P3_5=P3^5;
sbit P3_6=P3^6;
sbit k=P1^0;
sbit k1=P1^1;
sbit L1=P3^6;
sbit L2=P3^5;
sbit L3=P3^3;
sbit S=P3^4;
sbit rs=P2^4;
sbit rw=P2^5;
sbit en=P2^6;

void write_LCD_command(uchar command)//命令写入LCD
{
rw=0;//写入LCM
rs=0;//指令寄存器
en=1;//始能端
P0=command;//写命令
delay(20);//延时40*20us
en=0;//关闭始能端
rw=1;//读取LCM
}

void write_LCD_data(uchar data_a)//数据写入LCD//.......2
{
rw=0;
rs=1;
en=1;
P0=data_a;
delay(1);//40us
en=0;
rw=1;
}
void init_1602(void)//初始化LCD/////...................3
{
write_LCD_command(0x38);// 0x38 单行显示//8位传输
write_LCD_command(0x0c);// 0x0C 屏幕开启//光标不出现//不闪烁

}
void clear_LCD()//LCD清屏...........................4
{
write_LCD_command(0x01);//0x01 LCD清屏
write_LCD_command(0x02);//0x02 光标回到左上角
}

void delay(uint k)//延时..................................8
{
k=10*k;//40us
while(k--);
}



//main ()
main(unsigned int i,unsigned char str[])
{
if(k==1)
L3=1;
else
L3=0;

if(k1==0)
{
L2=0;
L1=1;
S=0;
}
else
{
L1=0;
L2=1;
S=1;
delay(10);
S=0;
delay(5);
L2=0;
}
str[]={"state=11111111"};

str[7]=P1^0;
str[8]=P1^1;
str[9]=P1^2;
str[10]=P1^3;
str[11]=P1^4;
str[12]=P1^5;
str[13]=P1^6;
str[14]=P1^7;
for(i=0;i<16;i++);
write_LCD_data(str[i]);
}
...全文
9244 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
YYATG 2011-08-22
  • 打赏
  • 举报
回复
/*#include "reg51.h"

main()
{
while(1)
{
char string[3][3] =
{
{0x00,0x01,0x02},
{0x03,0x04,0x05},
{0x06,0x07,0x08}
}
char *P;
P = &string[0][1];
//P++;
//P++;
P0 = *P;
//unsigned
}

}
*/

#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
void delay(uint k);
void delayus(uint k);
//延时
void write_LCD_command(uchar command);
//命令写入LCD
void write_LCD_data(uchar data_a);
//数据写入LCD
void init_1602(void);
//初始化LCD
void clear_LCD();
//LCD清屏
sbit P1_0=P1^0;
sbit P1_1=P1^1;
sbit P3_3=P3^3;
sbit P3_4=P3^4;
sbit P3_5=P3^5;
sbit P3_6=P3^6;
sbit k=P1^0;
sbit k1=P1^1;
sbit L1=P3^6;
sbit L2=P3^5;
sbit L3=P3^3;
sbit S=P3^4;
sbit rs=P2^4;
sbit rw=P2^5;
sbit en=P2^6;

void write_LCD_command(uchar command)//命令写入LCD
{
rw=0;
//写入LCM
rs=0;
//指令寄存器
en=1;
//始能端
P0=command;
//写命令
delay(20);
//延时40*20us
en=0;
//关闭始能端
rw=1;
//读取LCM
}

void write_LCD_data(uchar data_a)//数据写入LCD//.......2
{
rw=0;
rs=1;
en=1;
P0=data_a;
delay(1);
//40us
en=0;
rw=1;
}
void init_1602(void)//初始化LCD/////...................3
{
write_LCD_command(0x38);
// 0x38 单行显示//8位传输
write_LCD_command(0x0c);
// 0x0C 屏幕开启//光标不出现//不闪烁

}
void clear_LCD()//LCD清屏...........................4
{
write_LCD_command(0x01);
//0x01 LCD清屏
write_LCD_command(0x02);
//0x02 光标回到左上角
}

void delay(uint k)//延时..................................8
{
k=10*k;
//40us
while(k--);
}



//main ()
main(unsigned int i,unsigned char str[])
{
if(k==1)
L3=1;
else
L3=0;

if(k1==0)
{
L2=0;
L1=1;
S=0;
}
else
{
L1=0;
L2=1;
S=1;
delay(10);
S=0;
delay(5);
L2=0;
}

str ="state=11111111";//就是赋值的一点小问题
str[7]=P1^0;
str[8]=P1^1;
str[9]=P1^2;
str[10]=P1^3;
str[11]=P1^4;
str[12]=P1^5;
str[13]=P1^6;
str[14]=P1^7;
for(i=0;i<16;i++);
write_LCD_data(str[i]);
}
//帮你整理了下你也在学么,一起学吧A.A
gl007001 2011-06-28
  • 打赏
  • 举报
回复
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
报的错是说没找到函数声明,忘了在哪一个里面 都加上吧
logiciel 2010-05-29
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 direren 的回复:]
2楼的朋友,我换完之后出现了'strcpy' requires ANSI-style prototype 的错误
[/Quote]

增加#include <string.h>
direren 2010-05-28
  • 打赏
  • 举报
回复
2楼的朋友,我换完之后出现了'strcpy' requires ANSI-style prototype 的错误
direren 2010-05-28
  • 打赏
  • 举报
回复
对,就是那一行
l443638374 2010-05-28
  • 打赏
  • 举报
回复
学习ing
jixingzhong 2010-05-28
  • 打赏
  • 举报
回复
在c语言中,除非是初始化,否则对字符串需要通过操作函数进行操作:
str[]={"state=11111111"};
==>
strcpy(str,"state=11111111");
logiciel 2010-05-28
  • 打赏
  • 举报
回复
是这行有问题吗?
str[]={"state=11111111"};

70,018

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧