Use of " ? : " in format param to printf

Andrew Koenig ark at alice.UUCP
Fri Jan 20 08:05:25 AEST 1989


In article <1454 at leah.Albany.Edu>, rds95 at leah.Albany.Edu (Robert Seals) writes:

>     printf(count == 0 ? " ---- " : " %4.0lf ", sum / count);

> Does it matter if there are unused arguments to printf?

It's OK to have unused arguments in printf, but they'll be
evaluated whether they're used or not.  Thus in this example
if count is 0, the likely result is a divide by zero error.
-- 
				--Andrew Koenig
				  ark at europa.att.com



More information about the Comp.lang.c mailing list