Topic: BC 3.1 / ofstream help needed
Author: cybersf@netcom.com (Scott Fraley)
Date: Sat, 28 May 1994 03:12:26 GMT Raw View
Hello fellow developer(s),
My problem today is, I'm doing the following and its not working...
// open up the log file.
ofstream* pErrorOut = new ofstream;
pErrorOut->open( (char*)sLogFile, pErrorOut->ios::out, SH_DENYWR );
I'm pretty sure my 2nd & 3rd parameters are wrong, but I can't find a
good example of how to do this.
(Using Borland 3.1)
In the Borland help, it says..
>>
Declaration
void open(const char*, int, int = filebuf::openprot);
Remarks
Opens a file for an ofstream.
ios::out has been binarily included (ORed) into the mode (2nd parameter)
by default to ensure the file is opened for writing.
<<
Help also talks about the second parameter and mentions all of these 'ios'
members. I can't seem to find an example of this to save my life.
All I want to do, is open an output file, write a couple of lines to it, and
close the darn thing!
--
/--- | | | ----- /---\ /---\ |---- Scott Fraley
| | | | | | | cybersf@netcom.com (pref)
| \---/ |---\ ----- | \---\ |--- CI$: 71750,2173
| | | | | | | (no net mail to cis please)
\--- | |---/ ----- | \---/ | CyberSF@AOL.Com
Author: thomas@colargol.edb.tih.no (Thomas Fjaestad Hagelien)
Date: 28 May 1994 14:27:25 GMT Raw View
Scott Fraley (cybersf@netcom.com) wrote:
: Hello fellow developer(s),
: My problem today is, I'm doing the following and its not working...
: // open up the log file.
: ofstream* pErrorOut = new ofstream;
: pErrorOut->open( (char*)sLogFile, pErrorOut->ios::out, SH_DENYWR );
: I'm pretty sure my 2nd & 3rd parameters are wrong, but I can't find a
: good example of how to do this.
Try this:
pErrorOut->open(sLogFile, ios::out);
that's it, and that's that, well almost. But this'll let you open an
output file and write to "the darn thing" as you put it :)
Like this f.ex.
pErrorOut << "Is this really working?\n";
Now, do something useful :)
- Thomas