键盘扫描小问题

来源:百度知道 编辑:UC知道 时间:2024/05/17 20:50:10
#include"at89x52.h"
#define uchar unsigned char
const uchar number[16]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
// 8 9 a b c d e f
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
uchar m;
uchar a[4],b[4];
for(m=0x00;m<=0x03;m++)
{

}
void main()
{

}
这样写的话就会报错,错误是:
syntax error near 'for'
syntax error near '=' ,unexpected ')'
missing ';' before '<='
而我把for循环写在main函数里时就不会出错,请高手解释一下

const uchar number[16]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
// 8 9 a b c d e f
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
错了,number[16]应该改为number[]。

另外,(m=0x00;m<=0x03;m++) 可以简化为(m=0;m<=3;m++)