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
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 }
标签:test1,C51,int,void,unsigned,char,printf
来源: https://www.cnblogs.com/hehe2014/p/10445860.html