kelvSYC <> wrote:
(Assuming std::fopen behaves more or less like fopen() from C
> With std::fopen, will it return a null pointer if the file does not
> exist?
fopen returns a null pointer if the attempt to open the file fails.
This can happen for various reasons; one of which, of course, is that
the file does not exist. However, if the mode is "w" or "a", the file
will be created if it does not exist; if you get a null pointer in one
of these modes, something else has presumably gone wrong.
> If so, how do I make it so that it will attempt to create a
> file if it doesn't exist?
If you're opening for read, you can use "a+" as the mode; this will
open the file for read and write and create the file if it does not
exist.
> Would moving to fstreams/filebufs address
> these issues?
Probably, but I'll leave the answer to knowledgeable types.
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.