Xref: utzoo comp.sys.m6809:706 comp.lang.c:7987 Path: utzoo!mnetor!uunet!husc6!bloom-beacon!tut.cis.ohio-state.edu!mailrus!ames!pasteur!ucbvax!ucsfcgl!cca.ucsf.edu!rk9005 From: rk9005@cca.ucsf.edu (Roland McGrath) Newsgroups: comp.sys.m6809,comp.lang.c Subject: Re: Don't use Scanf() Message-ID: <1185@ucsfcca.ucsf.edu> Date: 11 Mar 88 02:36:59 GMT References: <2401@ihwpt.ATT.COM> <320@c10sd1.StPaul.NCR.COM> Reply-To: roland@rtsg.lbl.gov (Roland McGrath) Organization: Hackers Anonymous International, Ltd., Inc. (Applications welcome) Lines: 36 Keywords: C stdio library 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