Path: utzoo!mnetor!uunet!husc6!think!ames!umd5!uvaarpa!virginia!uvacs!rwl From: rwl@uvacs.CS.VIRGINIA.EDU (Ray Lubinsky) Newsgroups: comp.lang.c Subject: Why you should use puts(3) when you don't need printf(3) Message-ID: <2304@uvacs.CS.VIRGINIA.EDU> Date: 14 Mar 88 01:56:38 GMT Organization: U.Va. CS Department, Charlottesville, VA Lines: 15 True, if you use fprintf(3) (or printf(3) or sprintf(3) for that matter) once in a program, you have paid the penalty in terms of code size. And true, if you also use fputs(3) then you have added a little more size to your binary. But what ever happened to run time-efficiency? The point of using fputs(3) is that it just pushes bytes to the output! Fprintf(3) has to scan it's first argument and gyrate around to get to the point where it pushes bytes. The run-time size of fprintf(3) is just plain bigger. To give you an idea of the relative sizes, on my VAX 11/780 running 4.3 BSD, fputs is implemented as 60 lines of assembly code whereas _doprnt (the function that *printf calls -- another bit of overhead) is 396 lines. OK -- I'm not saying that using *printf where *puts is appropriate is going to break the bank. But it's good practice to only use what you need; anything else is just lazy programming.