Quote:
> Another question from a beginner... Is there any difference
> between printf( ... ) and (void)printf( ... )? Same for scanf.
printf() returns a value (the number of characters written or an
negative number to indicate an error). Simply calling printf() as in
your first example discards this return value. Casting its return
value to void tells the compiler that yes, you really do intend to
ignore the result. Some compilers and lints will warn you you are
ignoring the return value if you don't do this.
A similar thing happens with scanf() except that in this case it is
meaningful to check the return value because it tells you the number
of fields successfully read in. If you must use scanf() for input,
then you should make every effort to make sure you handle *all* the
input correctly.
Quote:
> Which form should I use? Thanks. FC.
For printf(), it's a matter of taste. Most people find the cast
overly picky, and few compilers or lints will warn about it's
omission. For scanf() the result can be used meaningfully, so it
shouldn't be being ignored.
--
http://www.geocities.com/SiliconValley/Lakes/7537/