Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!caen!ox.com!math.fu-berlin.de!uniol!sol.north.de!skuld!core!peic From: peic@core.north.de (Peter Eichler) Newsgroups: comp.lang.c Subject: Re: space allocation for sprintf() Message-ID: <1947acde.ARN00f8@core.north.de> Date: 10 Jun 91 18:15:10 GMT References: <1991Jun5.174543.266@dg-rtp.dg.com> Reply-To: peic@core.north.de (Peter Eichler) Followup-To: comp.lang.c Organization: Private UUCP-Site Lines: 32 In article <1991Jun5.174543.266@dg-rtp.dg.com>, Eric R Vook writes: > >Harbison & Steele p.328 contains the following parenthetical comment >after a discussion of sprintf(): >"(It is the programmer's responsibility to ensure that the destination > string area is large enough to contain the output generated by the > formatting operation.)" > ["C: A Reference Manual," 2nd ed, Harbison & Steele, p.328] > >I have just a short question, two-part question: > How do you know how much space to allocate? Well, look at the stuff you like to put into your destination string. If I'm printing 5000 floats, it should be more 100 Bytes... ;-) >Or > How do you know when you didn't allocate enough? If your machine crashes instantly, behaves strangely or your system crashes later, you WILL know (well maybe, case the error is often hard to find) > [...] >-Eric Cheerio, Peter Since pleasure is the Unique, to reveal Pleasure is itself a unique duty. FGTH ------------------------------------------------------------------------------ SNAIL:Peter Eichler \ Hegelstrasse 3 \ 2800 Bremen 1 \ Germany Amiga 3000 EMAIL:peic@core.north.de OR peic@skuld.north.de: VOICE:(+)49 421 530642