From: Martijn Klingens Newsgroups: comp.os.msdos.djgpp Subject: Re: Checking to see if I file exists Date: Thu, 23 Oct 1997 21:44:24 +0100 Organization: Delft University of Technology Lines: 14 Message-ID: <344FB728.E5E56BB@dutccis.ct.tudelft.nl> References: Reply-To: spaze AT dds DOT nl NNTP-Posting-Host: ct111n191.ct.tudelft.nl Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk H. Anthony Hoyt wrote: > > I can't seem to remember how to check to see if I file exists or not. > What I want is, if the user enters in a file name, to check to see if the > file exists. If so, I want to open the file, not overwrite it, read from > the file then recreate the file before I finaly save the file. (All in > binary) Any advice would be welcome. Thanks The most commonly used method is just to try opening the file. If fopen returns NULL, there was an error, so you can assume the file doesn't exist. You can ofcourse check what exactly went wrong, but in many cases assuming a file doesn't exist if fopen () returns NULL is pretty safe. Martijn Klingens