Mail Archives: djgpp/1997/10/16/07:34:53
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! *
*****************************************************
- Raw text -