Undelivered mail

MAILER%ALASKA.BITNET at CUNYVM.CUNY.EDU MAILER%ALASKA.BITNET at CUNYVM.CUNY.EDU
Sun Mar 13 07:52:29 AEST 1988


Subject:  Re: Don't use Scanf()

[Non-Deliverable:  User does not exist or has never logged on]

Reply-To: Info-C at BRL.ARPA

Received: From UWAVM(MAILER) by ALASKA with Jnet id 8626
          for SXJVK at ALASKA; Sat, 12 Mar 88 12:38 AST
Received: by UWAVM (Mailer X1.25) id 5868; Sat, 12 Mar 88 13:38:07 PST
Date:         Sat, 12 Mar 88 08:15:49 GMT
Reply-To:     Info-C at BRL.ARPA
Sender:       Info-C List <INFO-C at NDSUVM1>
Comments:     Warning -- original Sender: tag was nobody at sunybcs.uucp
From:         Fai Lau <ugfailau at sunybcs.uucp>
Subject:      Re: Don't use Scanf()
Comments: To: info-c at BRL-SMOKE.arpa
To:           Vic Kapella <SXJVK at ALASKA>

In article <1185 at ucsfcca.ucsf.edu> roland at rtsg.lbl.gov (Roland McGrath) writes:
>One real stupidity I've seen many, many times is the
>over-use of printf.  The printf functions have their uses,
>and they do their job quite well, but please know what these
>uses are!!

    C'mon!!! Is it really an issue?

>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 C compiler not
generating the almost same codes for both cases.

>or
>    printf("hi");
>try fputs:
>    fputs("hi", stdout);    /* no newline appended    */
>What's that?  Oh, now you have to include <stdio.h> so
>you can get the proper declarations of all these functions anyway?
>Poor baby!

    <stdio.h> should be included in mostly every program
just so that when you do need it you have it around. It's not
gonna give you a bigger or slower program.

>And the ultimate stupidity:
>    printf("\n");
>Get a brain!!!!!  You're using the function that can do complex
>data formatted output to write one bleeping character!!!!!
>Try
>    putchar('\n');
>If you include <stdio.h>, this will probably end up being a macro
>that will write it out very fast.
>
>I have even seen:
>    sprintf(buf, "constant string");
>Hey, Mr. Power-Programmer, ever heard of strcpy????

    Let's face it. The best way to give efficiency to a program
is to write your own macro to handle file I/O and strings. Macros like
strcpy are too general if you want to be picky.
    For example, if you want to print a string fast, you would write
a routine that uses only putc with no format capacity and no error
checking whatsoever, and forget about printf. Most of what you
said are true. But if one has to be as picky as you suggest, then
let's forget about stdio.h and strings.h and write everything from
the ground up.

Fai Lau
SUNY at Buffalo (The Arctic Wonderland)
UU: ..{rutgers,ames}!sunybcs!ugfailau
BI: ugfailau at sunybcs INT: ugfailau at joey.cs.buffalo.EDU



More information about the Comp.lang.c mailing list