这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界» 论坛首页» 嵌入式开发» MCU» Keil C51中Printf 与标准C有别

共1条 1/1 1 跳转至

Keil C51中Printf 与标准C有别

助工
2014-10-08 21:01:47 打赏
QUESTION

I can get the printf command to work with integers but not long integers or 8-bit integers. Why?


ANSWER


KEIL里扩展出了b,h,l来对输入字节宽的设置:
(1)b八位
(2)h十六位
(3)l三十二位


在Keil C51中用printf输出一个单字节变量时要使用%bd,如
unsigned char counter;
printf("Current count:%bd\n", counter);

而在标准C语言中都是使用%d:
printf("Current count: %d\n", counter);


共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册]