delorie.com/archives/browse.cgi | search |
From: | Jonathan Foster <jgf1 AT ukc DOT ac DOT uk> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: sprintf() string length? |
Date: | Thu, 16 Oct 1997 09:53:55 +0100 |
Organization: | University of Kent at Canterbury, England |
Lines: | 22 |
Message-ID: | <3445D623.605E@ukc.ac.uk> |
References: | <3 DOT 0 DOT 16 DOT 19971014214406 DOT 2c573b3e AT hem1 DOT passagen DOT se> |
NNTP-Posting-Host: | dhcp2dc9.ukc.ac.uk |
Mime-Version: | 1.0 |
CC: | blizzar AT hem1 DOT passagen DOT se |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
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.) -- Jon Foster. (1st Year Maths/Computer Science Student)
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |