, , - . , .
is_open, ifstream, ofstream, fstream. :
bool is_open (); // true , false -
f1:
if (!f1.is_open())
cout << "Input file can't be opened.\n";
, :
if (!f1)
cout << "Input file can't be opened.\n";
, , eof, ios, , , ifstream. :
bool eof(); // true , false -
, true, , . , "" . , , -, eof true .
() -
<< >>, istream ostream, - . - "" , , .
get put
() get, :
istream& get (char& ch);
() put:
ostream& put (char ch);
get, , () ch. - (, , ) , , .
put, , () ch.
ofstream f6("d:\\test.txt");
char c1;
in.get(c1); // c1
f6.put(c1); // c1 f6
get, :
istream& get (char *buf, streamsize num);
istream& get (char *buf, streamsize num, char delim);
int get();
streamsize int. get , buf, ( num-1 ) . ( "Enter") , delim . , . buf get .
|
|
get , , EOF, .
, >>, get , .
getline
getline, .
istream& getline (char *buf, streamsize num);
istream& getline (char *buf, streamsize num, char delim);
streamsize int. , 1 , -, . getline , buf, , num-1 . , ( "Enter" ('\n' '\xA'), , delim. , . buf getline .
getline get, . , getline ( "Enter"), get, >>, .
read write
- read write:
istream& read (char* buf, int nCount);
ostream& write (const char* buf, int nCount);
read nCount () , buf. write nCount (), , buf.