Mail Archives: djgpp/1998/11/21/00:22:28
Hello,
According to my trusty book here, ofstream defaults to using
ios::trunc when opening file.. Meaning all output-files should be truncated
by default. My problem is that when I don't trust GCC and use the following
statement:
ofstream someFile("hello.txt", ios::trunc);
Looking at the implementation I found the problem.. The constructor
defaults "mode" to "ios::out" .. when I use ios::trunc in place and override
the default, the file knows it should open in truncate mode, but it does not
know to open in output mode. I believe this is an implementation fault: no
matter what the programmer specifies, ofstream should ALWAYS use ios::out and
when someone chooses to do
ofstream someFile("hello.txt", ios::trunc);
like me, it should know that really means ios::out|ios::trunc.. After
all, that *is* the definition of the ofstream class. Any suggestions,
comments?
Gili
- Raw text -