Writing to A NON-Existing File in \"C\"

Michael J. Chinni, SMCAR-CCS-E mchinni at ardec.arpa
Thu Apr 7 05:32:06 AEST 1988


In a message from Michael Deutsch  <deutsch at jplgodo.uucp> 
dated 6 Apr 88 03:47:17 GMT he writes:

 > I have a "C" program that records the program
 > results into a file, provided that file already
 > exists.  In case the file DOES NOT exist I want
 > the program to function identically but the results
 > should be flushed down the tube, i.e. nowhere, i.e.
 > written to a non-existing file?
 > 
 > What sort of "file pointer" or trick should I use
 > to accomplish my goal?
I have a couple of suggestions.  First, try writing to "/dev/null".
Second, a temporary file could be used ("mkstemp" in BSD or "tmpnam"/"tempnam"
and "tmpfile" in SysV).  Last, a filename of personal choice could be created,
written to, and then deleted at the end of the program.

	Mike Chinni
        US Army Armament Research, Development, and Engineering Center
        Picatinny Arsenal, New Jersey  07806-5000
        AUTOVON: 880-4140
        MILNET:  <mchinni at ardec>
        COMMERCIAL: (201) 724-4140

------
Standard Disclaimer
------



More information about the Comp.unix.wizards mailing list