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);
  printf("\n");
  return 0;
}

"This shows that the format argument of printf can be an 
expression too", say K&R.

David

Reply via email to