Mail Archives: djgpp/1997/10/26/07:02:08
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
- Raw text -