On Mon, Sep 22, 2008 at 4:19 PM, David Hamill <[EMAIL PROTECTED]> wrote:
> I wrote:
>> (I can't immediately think of a case where I've
>> needed this capability, but it's nice to know it's
>> possible!)
>
> Coincidentally I ran across this example in Kernighan &
> Ritchie. It prints the program's command-line arguments
> separated by spaces. The format string is chosen at runtime
> as either "%s " or "%s":
>
> #include <stdio.h>
>
> main(int argc, char *argv[])
> {
> while (--argc > 0)
> printf((argc > 1) ? "%s " : "%s", *++argv);
I'm failing to see the point here. Is there something missing? Lost in
translation? I suspect possibly an s or a \n is missing judging from
the test.
> printf("\n");
> return 0;
> }
>
> "This shows that the format argument of printf can be an
> expression too", say K&R.
--
PJH
http://shabbleland.myminicity.com/ind