Similar Threads:
1.printf warning: "format %08x expects format unsigned int ..."
Andreas Eibach wrote:
> .... but I have an unsigned long value in the printf.
> This warning came when I used gcc 4.x to compile.
> ....
> unsigned long offset = 0;
> ....
>
> Well OK, an "easy" way would be instead of
>
> printf ("eof found at offset %08x", offset);
> to do a type cast like
"cast"
> printf ("eof found at offset %08x", (unsigned int) offset);
>
> Fine, but is this supposed to work for values like 0xFFFFFFFF, which is
> afaik the last possible long value. Unsigned int only goes to 0xFFFF.
>
"08lx" should do the job for unsigned long.
--
Ian Collins
2.C99 printf formats (2)
Hello, I have a new question about printf:
what is the correct output of printf("%#x", 0); ? (or with 0U for the
anal-retentive :)
According to my understanding of the standard, it is undefined
behaviour (the behaviour is defined only for nonzero values), so it
could output anything, including "pi=4".
All the libraries that I know will display "0" like for the %#o case
which is clearly specified.
Regards,
Adrian
3.printf(): giving format to an unsigned long questions
Hi
I would like to print on a win cmd console a register value, the value
is an "unsigned long" and have some output like these:
Register: 0x00000000
Tryed with
printf("Register: %#010lx \n", register);
printf("Register: %#08lx \n", register);
but I get 0x000003, only the first 6 values ??? from LSB to MSB,
normally MSBs are cero, but I would like to see them all.
Is there a way to print, hexadecimal, the hole 32 bits and add a nice
0x at the beginning?
I have read some books, googled and couldn't give a solution, any help
or info would be kindly appreciated.
Best Regards
4.Inverse of printf %x format
I've seen several postings asking this, but no simple, clear answer. My
C language reference book is deficient in this area.
If I
short i = 0;
printf(">%2x<",i);
I might resonably expect the following output:
>0000<
Now, what format code (%?? below) will restore i's value? e.g.
short i;
char s[5];
strcpy(s,"0000");
sprintf((char *)&i,"%??",s);
if (i==0) printf(">Hexed again<");
Produces:
>Hexed again<
Thanks in advance
5.printf format for double
Is it possible to print a float or double in exponential form with a 0
before the decimal point?
E.g. 0.1234567E+00 rather than 1.2345670E-01 (using %14.7E) ? As far as I
understand the format specifies in n1256, this isn't possible, is it?
Bye, Jojo
6. max size for printf() format conversion?
7. Problem with printf formats
8. printf() formatting - stripping zeroes, padding