Message-Id: <3.0.16.19971016132047.34a756c4@hem1.passagen.se> Date: Thu, 16 Oct 1997 13:26:49 -0400 To: Jonathan Foster From: Peter Palotas Subject: Re: sprintf() string length? Cc: djgpp AT delorie DOT com Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Precedence: bulk At 09.53 1997-10-16 +0100, you wrote: >Peter Palotas wrote: >> >> Is there a way to find out the length of the string that sprintf() will >> generate, without writing it anywhere? i.e. if I want to dynamically >> allocate the storage space for the string this would be very good (read >> essential) to know! >> >> -- Peter Palotas alias Blizzar -- blizzar AT hem1 DOT passagen DOT se -- > >I once read a solution to this (can't remember where though!): > >The "fprintf" command will return the number of characters output, >and you should fopen DOS's "NULL" file to send the output to. >"NULL" is a "black hole" which will swallow and ignore anything you >send to it. Although "NULL" never appears in a directory, it >exists everywhere. (I think the UNIX equivalent is "/dev/nul", >but I've never used UNIX.) Does anyone know if this works, and how compatible it is? Writing to a NULL pointer doesn't sound too good to me! -- Peter Palotas alias Blizzar -- blizzar AT hem1 DOT passagen DOT se -- ***************************************************** * A brief description of DJGPP: * * NEVER BEFORE HAS SO FEW DONE SO MUCH FOR SO MANY! * *****************************************************