Writing to A NON-Existing File in "C"

Chert Pellett elwiz at killer.UUCP
Mon Apr 25 15:00:24 AEST 1988



How about just try:

int fd;

fd = open (FILENAME, O_APPEND| O_RDWR);	 /* Will fail if file not there */

if (fd < 0)
	fd = open ("/dev/null", O_RDWR); /* Discard output, as per original 
                                           article */

if you want to use stdio, use the fdopen (fd, "w+") to get your
FILE * type...



	-- Chert Pellett

(why would anyone use stat/access then have to do an open call?)



More information about the Comp.unix.wizards mailing list