Path: utzoo!attcan!utgpu!watmath!maytag!aries5!giguere From: giguere@aries5.uucp (Eric Giguere) Newsgroups: comp.sys.amiga.tech Subject: Re: strins() Keywords: Lattice C Manx Aztec C strins() sprintf Message-ID: <256@maytag.waterloo.edu> Date: 14 Jun 89 08:34:11 GMT References: <0929.AA0929@caleb> <109394@sun.Eng.Sun.COM> <10285@watcgl.waterloo.edu> <384@xdos.UUCP> Sender: daemon@maytag.waterloo.edu Reply-To: giguere@aries5.waterloo.edu (Eric Giguere) Organization: Computer Systems Group, University of Waterloo Lines: 33 In article <10285@watcgl.waterloo.edu> gswan@watcgl.waterloo.edu (Geo Swan) writes: >I have seen lots of code that builds strings, particularly pathnames >through the use of several calls to strcat. I have never been able >to understand why people didn't use sprintf. Particularly in the >case of building pathnames. If you're trying to write small programs with as little library overhead as possible you should avoid any of the (f/s/v)printf routines if at all possible. As anyone who's looked through the bowels of a C compiler knows, the printf routines are some of the largest routines around and non-trivial to code. That's why the standard program main() { printf( "hello, world\n" ); } is actually more of a test for the C compiler than you'd normally think. A routine like strcat is for the most part just a tight loop that moves characters around and is very economical. Having said that, once you've used printf even once in a program you might as well use the others if convenient (and if not too slow for you) since the code is there already (fprintf, sprintf, vprintf and printf are all front-ends to a central format routine). At least in Aztec C (and Lattice, I assume) printf isn't too bad if you don't use any floating-point functions. Eric Giguere 268 Phillip St #CL-46 For the curious: it's French ("jee-gair") Waterloo, Ontario N2L 6G9 Bitnet : GIGUERE at WATCSG (519) 746-6565 Internet: giguere@aries5.UWaterloo.ca "Nothing but urges from HELL!!"