Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!adm!MAILER%ALASKA.BITNET@CUNYVM.CUNY.EDU From: MAILER%ALASKA.BITNET@CUNYVM.CUNY.EDU Newsgroups: comp.lang.c Subject: Undelivered mail Message-ID: <12364@brl-adm.ARPA> Date: 13 Mar 88 15:40:16 GMT Sender: news@brl-adm.ARPA Lines: 34 Subject: Re: Don't use Scanf() [Non-Deliverable: User does not exist or has never logged on] Reply-To: Info-C@BRL.ARPA Received: From UWAVM(MAILER) by ALASKA with Jnet id 1172 for SXJVK@ALASKA; Sun, 13 Mar 88 06:14 AST Received: by UWAVM (Mailer X1.25) id 7080; Sun, 13 Mar 88 07:14:16 PST Date: Sun, 13 Mar 88 00:58:41 GMT Reply-To: Info-C@BRL.ARPA Sender: Info-C List From: Henry Spencer Subject: Re: Don't use Scanf() Comments: To: info-c@BRL-SMOKE.arpa To: Vic Kapella > For example, if you want to print a string fast, you would write > a routine that uses only putc... !!NO!! If you want to print a string fast, you use fputs and insist that your supplier implements it properly. Putc has to do things like buffer- overflow checking on every character; a fast implementation of fputs can inspect the buffer *once*, note that there is room for N more characters, copy N characters at high speed, and then update counts and so forth *once*. This is a major efficiency win over putc if you are doing it a lot. Unfortunately, not all implementors make the effort to make stdio fast. In general, System V stdios are fast and 4BSD ones are not. (There are exceptions to this, both ways, and I believe the 4BSD one is going to be improved.) -- Those who do not understand Unix are | Henry Spencer @ U of Toronto Zoology condemned to reinvent it, poorly. | {allegra,ihnp4,decvax,utai}!utzoo!henry