完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
求高手指教,如何改,谢谢! 程序: /******************main.c文件程序源代码*************************/ #include #include #define uint unsigned int #define uchar unsigned char unsigned char step = 0; //操作步骤 unsigned char oprt = 0; //运算类型 signed long num1 = 0; //操作数1 signed long num2 = 0; //操作数2 signed long result = 0; //运算结果 unsigned char TORH = 0; //TO重载值的高字节 unsigned char TORL = 0; //TO重载值的低字节 void Configtimer0 ( unsigned int ms); extern void KeyScan(); extern void KeyDriver(); extern void InitLcd1602(); extern void LcdShowStr( unsigned char x, unsigned char y, unsigned char * str); extern void LcdAreaClear( unsigned char x, unsigned char y,unsigned char len ); extern void LcdFullClear(); void main() { EA = 1; //开总中断 ConfigTimer0(1); //配置TO定时1ms InitLcd1602(); //初始化液晶 LcdShowStr(15,1,"0"); //初始显示一个数字0 while(1) { KeyDriver(); //调用按键驱动 } } /*长整型数转换为字符串,str为字符串指针,dat为待转换数,返回值为字符串长度*/ unsigned char LongToString(unsigned char * str,signed long dat) { signed char i = 0; unsigned char len = 0; unsigned char buf[12]; if(dat < 0) //如果为负数,首先取绝对值,并在指针上添加负号 { dat = -dat; * str++ = '-'; len++; } do{ //先转换为低位在前的十进制数组 buf[i++] = dat % 10; dat/=10; }while(dat > 0); len += i; //i最后的值就是有效字符的个数 while(i-- > 0 ) //将数组值转换为ASCII码反向拷贝到接收指针上 { * str++ = buf[i] + '0'; } * str = ' |