in the keil c51 users manual, page 295
I found this example about printf formatting (see below)
some of the formatting type fileds have a "b" letter after the "%" symbol.
is there an explanation of what this "b" character does?
thank you
Fausto Bartra
#include <stdio.h>void tst_printf (void) {char a;int b;long c;unsigned char x;unsigned int y;unsigned long z;float f,g;char buf [] = "Test String";char *p = buf;a = 1;b = 12365;c = 0x7FFFFFFF;x = 'A';y = 54321;z = 0x4A6F6E00;f = 10.0;g = 22.95;printf ("char %bd int %d long %ld\n",a,b,c);printf ("Uchar %bu Uint %u Ulong %lu\n",x,y,z);printf ("xchar %bx xint %x xlong %lx\n",x,y,z);printf ("String %s is at address %p\n",buf,p);printf ("%f != %g\n", f, g);printf ("%*f != %*g\n", 8, f, 8, g);}
The letter "b" is therefore a byte qualifier:
printf("char %d",a);
first converts the variable "a" into an integer and then outputs it, but
printf("char %bd",a);
does not convert the variable "a" into an integer and is therefore more suitable for a device that is very resource-limited. However, both examples have the same effect, namely the output of the char variable "a" on the standard output.
Franc:Thank you