Re: ofstream no longer has file permissions?
"Don Newell" <[email protected]>
| Newsgroups | gmane.comp.programming.cppug |
|---|---|
| Organization | The Free Electron |
| Message-ID | <001401c48974$1c905850$6235fea9@PCXP> |
OFSTREAM CLASS
from "Learning to Program in C++"
by Steve Heller [ ISBN 0-13-032410-8 ]
#include <fstream.h>
.
.
.
ifstream inData;
ofstream outData;
ofstream OutputStream("test.out");
// ********************* sample use ***
#include <fstream.h> // required
int
main( ) {
ofstream f_out; // f_out is declared as an object of the ofstream class
f_out.open( "test.out" );
if ( f_out.fail ( ) ) {
cerr << "Error opening file. \n":
return 1;
}
f_out << "This is a test. \n" ;
f_out.close ( );
return 0;
}
// an ofstream is a stream used to write to a [disk, e.g.] file.
// cannot find any other examples in the usage of ofstream
>From page 614:
"The relationship between a base class and a publicly derived class
is commonly expressed by saying that the derived class "isA" base
class object. [14]
14. By the way, this is the reason it's all right to provide an ofstream variable
where an ostream is expected, as I told Susan in the discussion on page 583.
Because ofstream is publicaly derived from ostream, an ofstream "isAn"
ostream. This means that you can provide an ofstream wherever an ostream
is specified as an arguement or return type.
They are using a RHIDE compiler IDE.
Also see: www.gcom.com/home/linux/lis/>project
HTH
Don
Please, Pray for Tina Lynn Hayden.
----- Original Message -----
From: dj_segfault
To: [email protected]
Sent: Monday, August 23, 2004 3:05 PM
Subject: [cppug] ofstream no longer has file permissions?
I'm porting some code from AIX's xlC compiler to gcc. One of the
problems I'm banging my head against right now is this one particular
use of an of an ofstream. The current call looks like:
ofstream fstrm(cstrFileName,ios::out,0640);
(cstrFileName is a Rogue Wave string, but that's not the issue,
because I can just use cstrFileName.data()).
The ofstream in gcc, and as far as I can tell the C++ standard, does
not have the third parameter for file permissions. Am I missing
something? There doesn't seem to be another way of ensuring the file
has the right permissions, is there?
Thanks in advance.
Yahoo! Groups Sponsor
ADVERTISEMENT
------------------------------------------------------------------------------
Yahoo! Groups Links
a.. To visit your group on the web, go to:
http://groups.yahoo.com/group/cppug/
b.. To unsubscribe from this group, send an email to:
[email protected]
c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.