(istream ostream) , .
:
enum stream_state { _good, _eof, _fail, _bad };
_good _eof, , _good, , . , , _good, . , , :
switch (cin.rdstate()) {
case _good: // cin
break;
case _eof: //
break;
case _fail: //
break;
case _bad: // , cin
break; }
- ++
++ -, :
ios //
streambuf //
istream //
ostream //
iostream //
istrstream //
ostrstream //
strstream //
ifstream //
ofstream //
fstream //
(istream,ostream,iostream) . (istrstream, ostrstream, strstream) - , , (ifstream, ofstream, fstream) .
- fstream.h, istream ostream ifstream, ofstream fstream, . :
ifstream in;//
ofstream out;//
fstream io;// -
:
ofstream obj (filename, mode),
ifstream obj (filename, mode),
mode :
ios::app //
ios::ate //
ios::binary /* ( ) */
ios::in //
ios::nocreate // ,
ios::noreplace // ,
ios::out //
ios::trunc // ,
: ios::app|ios::noreplace
fstream:
fstream obj(filename, ios::in|ios::app);
, , , open():
void open (char *filename,int mode,int access), filename , ; mode , access . ccess : 0 , 1 , 8 . :
ofstream out;
out.open(test.dat,ios::out,0);
.
ut.open(test.dat);//
. close().