C51 printf

 

char putchar (char c)
{
    ES=0;
    SBUF = c;
    while(TI==0);
    TI=0;
    ES=1;
    return 0;
}

 

void main()
{
    unsigned char test1 = 55;
    printf(“the test is %d\r\n”,test1);
}

 

void main()
{
    unsigned char test1 = 55;
    printf(“the test is %d\r\n”,(int)test1);
}

 

格式 含义 针对类型
%d 两个字节变量 int
%bd 单字节变量 char
%ld 四字节变量 long int

void main()
{
    unsigned char test1 = 55;
    printf(“the test is %bd\r\n”,test1);
}

 

 1 #include <stdio.h>
 2 
 3 void tst_printf (void)
 4 {
 5     char a = 1;
 6     int b = 12365;
 7     long c = 0x7FFFFFFF;
 8 
 9     unsigned char x = ‘A’;
10     unsigned int y = 54321;
11     unsigned long z = 0x4A6F6E00;
12 
13     float f = 10.0;
14     float g = 22.95;
15 
16     char buf [] = “Test String”;
17     char *p = buf;
18 
19     printf (“char %bd int %d long %ld\n”, a, b, c);
20     printf (“Uchar %bu Uint %u Ulong %lu\n”, x, y, z);
21     printf (“xchar %bx xint %x xlong %lx\n”, x, y, z);
22     printf (“String %s is at address %p\n”, buf, p);
23     printf ("%f != %g\n", f, g);
24     printf ("%*f != %*g\n", (int)8, f, (int)8, g);
25 }

 

转载于:https://www.cnblogs.com/hehe2014/p/10445860.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值