Xref: utzoo comp.sys.m6809:713 comp.lang.c:8117 Path: utzoo!mnetor!uunet!husc6!bbn!rochester!cornell!svax!belmonte From: belmonte@svax.cs.cornell.edu (Matthew Belmonte) Newsgroups: comp.sys.m6809,comp.lang.c Subject: Re: Don't use Scanf() Message-ID: <2057@svax.cs.cornell.edu> Date: 13 Mar 88 06:09:41 GMT References: <2401@ihwpt.ATT.COM> <320@c10sd1.StPaul.NCR.COM> <1185@ucsfcca.ucsf.edu> <9241@sunybcs.UUCP> Reply-To: belmonte@sleepy.cs.cornell.edu (Matthew Belmonte) Followup-To: /dev/null Organization: Cornell Univ. CS Dept. Lines: 39 Keywords: C stdio library Summary: why bother? In article <9241@sunybcs.UUCP> ugfailau@sunybcs.UUCP (Fai Lau) writes: > C'mon!!! Is it really an issue? It shouldn't be. This discussion reminds me of a time a few years ago when I was living near Washington, D.C. and someone on a local BBS decried the use of comments in source code because they increase compilation time. >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 [sic] C compiler not >generating the almost same codes for both cases. Imagine again. The generated code will be a push of the address of the argument (in the above examples, a constant string) onto the stack, followed by a jump-to-subroutine to the called function, either _printf or _puts. Thus, the object codes are completely disparate. But this doesn't alter the fact that IT JUST DOESN'T MAKE ENOUGH DIFFERENCE FOR THE PROGRAMMER TO CARE. printf and puts are both linear-time algorithms. printf probably takes a little longer because it has to check for embedded format strings, but it doesn't find any in this case, so the extra time is negligible. As for the space, someone already mentioned that the effect of chopping out library routines such as _printf is usually swamped by the effect of the operating system's block allocation scheme. Program images take constant space. It's only the data space that can get larger with problem size, and that's what you should be concerning yourselves with. There are some things worth devoting your time to, and there are other things better left alone. These are sometimes difficult to differentiate, but not in this case. YOU PEOPLE ARE NITPICKING. -- Matthew Belmonte Internet: belmonte@sleepy.cs.cornell.edu BITNET: belmonte@CRNLCS *** The Knights of Batman *** (Computer science 1, College 5, Johns Hopkins CTY Lancaster '87 session 1)