Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!indri!lll-winken!lll-lcc!pyramid!infmx!kevinf From: kevinf@infmx.UUCP (Kevin Franden) Newsgroups: comp.lang.c Subject: Re: printf() problem Keywords: C printf Message-ID: <1276@infmx.UUCP> Date: 27 Apr 89 22:09:10 GMT References: <11657@hodge.UUCP> <89Apr26.092233edt.18850@me.utoronto.ca> <518@cpsc6b.cpsc6a.att.com> Reply-To: kevinf@infmx.UUCP (Kevin Franden) Organization: Informix, Menlo Park, Ca. U.S.A. Lines: 42 In article <518@cpsc6b.cpsc6a.att.com> crs@cpsc6b.cpsc6a.att.com (Chris (I'm Outta Here!) Seaman) writes: >zougas@me.utoronto.ca ("Athanasios(Tom) Zougas") writes: >< jdm@hodge.UUCP (jdm) writes: >< > Perhaps someone could explain this printf() phenomena to me. > >[printf example deleted...] > [other stuff deleted...] >< What you did will correct it. Or try: >< >< for ( i = 0; i < 4; ++i ) { >< printf( "%x ", getc(fp) ); >< } >< printf( "\n" ); >< >< Of course, where you are gaining in not having to declare 4 variables, >< you are losing in 5 calls of printf. Trade-offs, trade-offs ... > >I hope this doesn't start a flame war, but IMHO, you should NEVER use >a function with all the overhead of printf() to output a simple linefeed. >putchar() or fputc() would do the same job, without all the overhead. > Um.... isn't the last printf "for free" 'cause it's already linked in from the other call? Once you call a routine it doesn't matter how MANY times you call it, right? I agree that it would be better to use puts(" ") or somthing (anything!) with less overhead to do such a trivial operation like printing a NL, but if you already used the (big, complex) code of printf, why not reuse it? Unless you're REAL concerned about saving clock cycles (puts being faster)... -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Kevin Franden UUCP: {backbone}!pyramid!infmx!kevinf Informix Software Inc disclaimer("I said what I said and not my employer"); =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=