Xref: utzoo comp.sys.m6809:715 comp.lang.c:8191 Path: utzoo!mnetor!uunet!mcrware!kim From: kim@mcrware.UUCP (Kim Kempf) Newsgroups: comp.sys.m6809,comp.lang.c Subject: Re: Don't use Scanf() Message-ID: <612@mcrware.UUCP> Date: 14 Mar 88 19:27:34 GMT References: <2401@ihwpt.ATT.COM> <320@c10sd1.StPaul.NCR.COM> <9241@sunybcs.UUCP> Organization: Microware Systems Corp., Des Moines, Ia. Lines: 23 Keywords: C stdio library In article <9241@sunybcs.UUCP>, ugfailau@sunybcs.uucp (Fai Lau) writes: >In article <1185@ucsfcca.ucsf.edu> roland@rtsg.lbl.gov (Roland McGrath) writes: >>One real stupidity I've seen many, many times is the >>... > > C'mon!!! Is it really an issue? > >>For example: >> printf("Hello world!\n"); > > I can't imagine any reasonably competant C compiler not >generating the almost same codes for both cases. > The issue here is not the code the compiler generates (its the same in either case) but the execution time expended. Given an arbitrary string to output, printf must look at each character checking for a '%' for format conversion. If no format conversions are desired, its much faster to use puts(). Furthermore, if the conversion string *does* contain a '%' and is not escaped, watch out! Consider the following: printf("It's 100%unusable!\n"); The output is unexpected at best.