Mail Archives: djgpp/1997/10/20/04:52:50
On Thu, 16 Oct 1997, Peter Palotas wrote:
(...)
> >
> >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 --
>
(...)
It is not a matter of writing to a null pointer.
It is a matter of writing to a pointer pointing to the file with the name
/dev/null (or the file named "nul" in dos).
i.e.:
...
FILE *nowhere;
int numchars;
nowhere = fopen("/dev/null", "w");
numchars = fprintf(nowhere, "how long is this string?");
...
Thomas
--
Thomas Knudsen | www: http://www.gfy.ku.dk/~tk/
National Survey and Cadastre - Denmark | e-mail: tk AT gfy DOT ku DOT dk
Geodetic office, Rentemestervej 8 | Direct Phone: +45 35 87 52 64
DK-2400 Copenhagen NV, Denmark | FAX: +45 35 87 50 52
- Raw text -