bug-hello
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: In hello.c, what governs whether puts, printf, or fputs is used?


From: Karl Berry
Subject: Re: In hello.c, what governs whether puts, printf, or fputs is used?
Date: Mon, 21 May 2007 17:18:46 -0500

    #1) What principles govern when hello.c print_help calls printf
    vs. puts vs. fputs?
    #2) What is the difference between puts("") and printf("\n") ?

puts is for literal strings written to stdout.
fputs is for literal strings written to other streams.
printf is for formatted strings written to stdout.
(fprintf is for formatted strings written to other streams. :)

In the old days, the difference between printf("...") and puts("...")
could be noticeable, so it was good practice to use [f]puts when it was
just a literal string being output.  These days, I expect [f]printf is
optimized so it makes no difference, but I still have the habit.

Best,
Karl




reply via email to

[Prev in Thread] Current Thread [Next in Thread]