printf function help

Rob Wehrli plug-devel@lists.PLUG.phoenix.az.us
Mon Mar 1 12:56:02 2004


On Mon, 1 Mar 2004, Tarun Karra wrote:

> my program still compiles and prints out value 34603777
>
> Can any one give me a reason for this output.
> thx
> tarun

Try using the -Wall switch with gcc.  This will then inform you of the
obvious:

warning: too few arguments for format

However, if you're bent on trying to find out WHY it still spews forth
some value, try stepping through it with gdb using the debug version of
the libc library.

What you're likely to find is that you're getting the libc initialized
address of the va_list argument for printf.  Of course, I could be
wrong, too.

It still doesn't make any sense to compile without the -Wall (warnings,
all) switch that will catch silly programmer errors such as not passing an
argument to a printf formatting function that isn't a "pure" string
literal.


Take Care.

Rob!