Don't use Scanf()

Wayne D. T. Johnson johnson at c10sd1.StPaul.NCR.COM
Tue Mar 15 06:57:59 AEST 1988


In article <2428 at ihwpt.ATT.COM> knudsen at ihwpt.ATT.COM (mike knudsen) writes:
>Good points.  But if you already are using printf() in your
>program (with a legitimate need for the formatting) in several
>places, then substituting puts() where possible will make
>your program object file bigger, not smaller, since
>now the puts() code has to be linked in too.
>Puts() and putchar() will be a little faster, but when you're
>talking to humans who cares?
>

Puts and putchar may seem to be only a little faster to humans only
until you use packages that do windowing and full page menus, or even
redirect your output to disk (ever write out 3.5 meg using a printf?).
besides, memory is cheap and getting cheaper but CPU time is still costing
quite a bit.

In several instances I have found that removing several printf's that
were in critical paths of our code has remarkable speeded things up.
        -Wayne



More information about the Comp.lang.c mailing list