Xref: utzoo comp.sys.m6809:731 comp.lang.c:8304 Path: utzoo!mnetor!uunet!mcvax!ukc!its63b!aiva!richard From: richard@aiva.ed.ac.uk (Richard Tobin) Newsgroups: comp.sys.m6809,comp.lang.c Subject: Re: Don't use Scanf() Message-ID: <296@aiva.ed.ac.uk> Date: 17 Mar 88 21:16:01 GMT References: <2401@ihwpt.ATT.COM> <320@c10sd1.StPaul.NCR.COM> <1185@ucsfcca.ucsf.edu> <9241@sunybcs.UUCP> <1140@csun.UUCP> Reply-To: richard@uk.ac.ed.aiva (Richard Tobin) Organization: Bannerman's Bar, Cowgate, Edinburgh Lines: 25 Keywords: C stdio library In article <1140@csun.UUCP> sef@csun.UUCP (Sean Fagan) writes: >Yes, it can be; since printf(3) is interpreted, it *WILL* be slower than >directly coding the correct statements. I.e., printf("Hello world!\n") is >slower than puts("Hello world!") which is slower than >write(1,"Hello world!\n",13). If you're doing a lot of I/O like this, it can >be significantly slower. The key phrase here is "If you're doing a lot of I/O like this". You would certainly have to execute this statement a large number of times for the interpretation to take longer than counting the characters in the string (maybe I just don't count fast :-). The computer's time is much less valuable than mine (to me, at least), so except in very rare circumstances I'm not going to think about how hard it is for the computer. I'm quite happy to put 'printf("\n")' in my programs, especially when it's surrounded by other calls to printf. Of course, printf() vs write() is also a portability question, but I'm sure there will be plenty of comments on that... -- Richard -- Richard Tobin, JANET: R.Tobin@uk.ac.ed AI Applications Institute, ARPA: R.Tobin%uk.ac.ed@nss.cs.ucl.ac.uk Edinburgh University. UUCP: ...!ukc!ed.ac.uk!R.Tobin