Xref: utzoo comp.sys.m6809:740 comp.lang.c:8499 Path: utzoo!mnetor!uunet!husc6!rutgers!mtune!mtunx!whuts!picuxa!gp From: gp@picuxa.UUCP (Greg Pasquariello X1190) Newsgroups: comp.sys.m6809,comp.lang.c Subject: Re: Don't use Scanf() Message-ID: <517@picuxa.UUCP> Date: 23 Mar 88 12:26:21 GMT References: <2401@ihwpt.ATT.COM> <320@c10sd1.StPaul.NCR.COM> <9241@sunybcs.UUCP> Organization: AT&T Information Systems, Parsippany NJ Lines: 36 Keywords: C stdio library Summary: it's not generated by the compiler. In article <9241@sunybcs.UUCP>, ugfailau@sunybcs.UUCP writes: > In article <1185@ucsfcca.ucsf.edu> roland@rtsg.lbl.gov (Roland McGrath) writes: > >For example: > > printf("Hello world!\n"); > >Haven't you ever heard of puts???? > > puts("Hello world!"); /* note the newline is appended */ > > I can't imagine any reasonably competant C compiler not > generating the almost same codes for both cases. These are library calls, and although the compiler will generate approximately the same function calling sequence, the linker will link in a much larger function in printf(). > Let's face it. The best way to give efficiency to a program > is to write your own macro to handle file I/O and strings. Macros like > strcpy are too general if you want to be picky. > For example, if you want to print a string fast, you would write > a routine that uses only putc with no format capacity and no error > checking whatsoever, and forget about printf. That is about what puts() does! However, rather than looping on putc(), the string is put directly into the buffer with memcpy(), which is quicker. Greg Pasquariello ihnp4!picuxa!gp