delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/16/12:46:34

From: mdruiter AT cs DOT vu DOT nl (Ruiter de M)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: sprintf() string length?
Date: 16 Oct 1997 14:01:16 GMT
Organization: Fac. Wiskunde & Informatica, VU, Amsterdam
Lines: 26
Message-ID: <6256nc$jtt$1@star.cs.vu.nl>
References: <3 DOT 0 DOT 16 DOT 19971014214406 DOT 2c573b3e AT hem1 DOT passagen DOT se> <3445D623 DOT 605E AT ukc DOT ac DOT uk>
NNTP-Posting-Host: sloep53.cs.vu.nl
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Jonathan Foster (jgf1 AT ukc DOT ac DOT uk) wrote:
: Peter Palotas wrote:
: > Is there a way to find out the length of the string that sprintf() will
: > generate, without writing it anywhere?

: The "fprintf" command will return the number of characters output,

I thought it returns the number of correctly parsed arguments after
the format string. But my Solaris man pages say you are right.

: and you should fopen DOS's "NULL" file to send the output to.

You mean NUL. Not very portable solution.

: "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.)

That's "/dev/null" or "/dev/zero". Works for DJGPP too, automagicly :)

-- 
Groeten, Michel.        http://www.cs.vu.nl/~mdruiter
 \----/==\----/
  \  /    \  /          "You know, Beavis, you need things that suck,
   \/      \/           to have things that are cool", Butt-Head.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019