# ># In article <
[email protected]>,
# >#
# ># > Hi, c.l.cs
# ># >
# ># > I noticed that someone like add (void) before the printf call,
# ># > like: (void) printf("Timeout\n"); while the others does't. So
# ># > can someone tell me whether there any gains in adding
# ># > (void) to printf.
# >#
# ># printf returns a value.
# >#
# ># When a function returns a value, and the programmer ignores the code, I
# ># would want to know why. There are usually two explanations: The
# ># programmer made a mistake ignoring the return value, or the programmer
# ># did ignore the return value on purpose. When you write
# >
# > I routinely notice lots of people checking the return of printf
# > instead of simply looking at the terminal window.
#
# Of course, sometimes just staring at terminals may be deceptive at
# times. Consider a program that prints whitespace separated words and
# shows two words on your terminal:
#
# hello world
#
# Have these been printed by a single call to printf?
#
# printf("hello world\n");
#
# Two successive calls?
#
# printf("hello ");
# printf("world\n");
What does that have to do with error checking?
# Or maybe three calls, where the middle one failed, for some obscure
# (and undetected by just staring at the output) reason?
#
# printf("hello ");
# printf("strange ");
# printf("world\n");
For some absurd reason if I see the above code in the .c but I don't see
"strange " in the output, I manage to realize something went wrong without
checking anything else.
I guess I have ESP.
At best the return can indicate something went wrong. To get the details
you'll need more information. Oft times, you get more information by
printfing to the terminal window.