Re: declaration of variable in for loop



In article <fns04t$ve0$1@xxxxxxxx>, santosh <santosh.k83@xxxxxxxxx> wrote:
poornimamprabhu@xxxxxxxxx wrote:

printf("%d %p = *%d\n",i,&k,k);

You probably want:

printf("%d\t%p = %d\n", i, (void *)&k, k);

Also the '*' character in your format string
specifies that the following formatting operation be of the minimum
field width specified by the corresponding argument to '*'. In this
case it is the fourth printf() argument and thus, the final 'd'
specifier is left without an argument, invoking undefined behaviour.

That only applies if the * follows the %. Outside of a % specifier,
an * represents the literal character '*'.
--
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth
.



Relevant Pages

  • Re: how to print a short and long integer?
    ... I understand the symmetry with scanf() where the short specifier is definitely ... needed for d,i,o,u,x or X conversions. ... If a short or insigned short is passed to printf, %d or %u will do the job. ...
    (comp.lang.c)
  • Re: calendar problem
    ... > int main ... or fat-fingered user who enters "e^H31". ... this printf() call. ... specifier like "%*d" and *two* argument values would do ...
    (comp.lang.c)
  • Re: (part1) Han from China teaches you C
    ... printf is documented to accept a "%I" conversion ... specifier which prints an unsigned int in a format suitable for input to ... Extra conversion specifiers to printf() are a clear case of implementation-defined behaviour. ...
    (comp.lang.c)
  • Re: One word to the right extreme and another to the left extreme
    ... I have a query based on the format ... int main ... Is ther any specifier to print the Hello World ... any of the format specifier in printf:- ...
    (comp.lang.c)
  • Re: printf mnemonic for the value returned by rdtsc/rdpmc
    ... >what I wrote but the bottom digits have a 900 which is coming out of ... printf has no way of knowing that. ... low-order dword of "result" happens to be 24, ... The next specifier, %llu, uses up 64 bits. ...
    (comp.lang.asm.x86)