Path: utzoo!mnetor!uunet!husc6!mailrus!nrl-cmf!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: <12296@brl-adm.ARPA> Date: 12 Mar 88 11:26:02 GMT Sender: news@brl-adm.ARPA Lines: 53 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 7390 for SXJVK@ALASKA; Sat, 12 Mar 88 01:57 AST Received: by UWAVM (Mailer X1.25) id 5026; Sat, 12 Mar 88 02:56:39 PST Date: Fri, 11 Mar 88 02:36:59 GMT Reply-To: Info-C@BRL.ARPA Sender: Info-C List From: Roland McGrath Subject: Re: Don't use Scanf() Comments: To: info-c@brl-smoke.arpa To: Vic Kapella 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!! For example: printf("Hello world!\n"); Haven't you ever heard of puts???? puts("Hello world!"); /* note the newline is appended */ or printf("hi"); try fputs: fputs("hi", stdout); /* no newline appended */ What's that? Oh, now you have to include so you can get the proper declarations of all these functions anyway? Poor baby! 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 , 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???? In general, if there's no format spec, don't use printf!!!!!! -- Roland McGrath ARPA: roland@rtsg.lbl.gov roland@lbl-rtsg.arpa UUCP: ...!ucbvax!lbl-rtsg.arpa!roland