home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!rutgers!cmcl2!panix!spencer
- From: spencer@panix.com (David Spencer)
- Newsgroups: comp.sys.mac.programmer
- Subject: printf and scanf (was: THINK C linker makes me sad)
- Message-ID: <1992Sep8.143032.14302@panix.com>
- Date: 8 Sep 92 14:30:32 GMT
- References: <fdrny7c.howard@netcom.com>
- Distribution: usa
- Organization: PANIX Public Access Unix, NYC
- Lines: 27
-
- howard@netcom.com (Howard Berkey) writes of THINK C:
-
- >So I was writing this really small, simple app. (a mac version of xclock,
- >just for fun.) It was only 3k. Then I added a call to sprintf(). It
- >exploded the program to 22k.
-
- Sic semper printf ["Thus be it always to printf", for the history- or
- latin-impaired].
-
- The printf functions are complex; they do a lot. The scanf functions
- are even worse. In any environment, they will explode code.
-
- They are also hard for the implementer to get right. THINK C, so far
- as I can tell, is OK. My $750 [list price] dos compiler/library has a
- printf that botches unsigned longs.
-
- Moreover, except for simple uses (for which putc or puts are
- adequate), they are hard for the user to get right.
-
- If possible, avoid printf and scanf (and cousins). Don't pay the
- overhead of all that formatting power, unless you need it. Use putc
- and puts (and getc and gets). If you know the output format, it's
- often easier (and certainly smaller) to write a custom formatter (no
- flames, please; I've just re-read Henry Spencer's _How to Steal Code_
- in penance for that statement...)
-
- dhs spencer@panix.com
-