Xref: utzoo comp.sys.m6809:712 comp.lang.c:8094 Path: utzoo!mnetor!uunet!mcvax!mhres!jv From: jv@mhres.mh.nl (Johan Vromans) Newsgroups: comp.sys.m6809,comp.lang.c Subject: Re: Don't use Scanf() Message-ID: <1673@mhres.mh.nl> Date: 12 Mar 88 14:00:25 GMT References: <2401@ihwpt.ATT.COM> <320@c10sd1.StPaul.NCR.COM> <1185@ucsfcca.ucsf.edu> Organization: Multihouse N.V., The Netherlands Lines: 38 Keywords: C stdio library In article <1185@ucsfcca.ucsf.edu> roland@rtsg.lbl.gov (Roland McGrath) writes: >One real stupidity I've seen many, many times is the >over-use of printf. The printf functions have their uses, >and they do their job quite well, but please know what these >uses are!! > > [examples of using puts, fput, putc instead of printf] > >And the ultimate stupidity: > printf("\n"); >Get a brain!!!!! You're using the function that can do complex >data formatted output to write one bleeping character!!!!! >Try > putchar('\n'); >If you include , this will probably end up being a macro ... If you don't you will likely end up with a missing routine ... >that will write it out very fast. Yes. But it does not flush if the output is a terminal or line-buffered. >In general, if there's no format spec, don't use printf!!!!!! I partly agree. When you are short on space, and want to eliminate the use of "large" routines like printf, you are right. On the other hand, you suggest the use of four or five different routines (with all different calling sequences) instead of one simple and elegant "printf" routine. Printf *CAN* do complex formatting, but it *DOESN'T* do this if you don't have format strings. What remains is just the tiny overhead of testing whether there are formatting characters in the string... I dislike discussions in which the quality of the arguments is measured by the number of exclamation marks following each sentence. -- Johan Vromans | jv@mh.nl via European backbone Multihouse N.V., Gouda, the Netherlands | uucp: ..{uunet!}mcvax!mh.nl!jv "It is better to light a candle than to curse the darkness"