/ (). C++ -, (-) .
( binary) , . . ( ) CR/LF LF ('\n') . , /. - -, ; , . . .
, , mode open() ios::binary.
read() istream:
istream &read(char *buf, long len);
buf , , len , .
write() ostream. , read():
ostream &write(char *buf, long len);
buf , , len , .
-. , , . . :
ostream os(...);
os.write(...).write(...).write(...);
, get istream. :
int get();
istream &get(char &c);
istream &get(char *buf, long len, char t = '\n');
. int get() . get (char &c) .
11.1
ifstream ifs("infile.dat");
ofstream ofs("outfile.dat");
// put (char)
// .
while (ifs & ofs)
ofs.put(ifs.get());
get() . buf, :
- t ( '\n');
- ;
|
|
- len , 0.
getline(), get():
istream &getline(char *buf, long len, char t = '\n');
, getline() , get() . , .
11.2 get()
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
setlocale(LC_ALL, "Russian");
char name[9], ext[4];
cout << " : ";
cin.get(name, 9, '.');
cin.ignore (80, '.'); //
cin.get(ext, 4);
cin.ignore(80, '\n'); // ,
cout<< ": "<< name << " : " << ext << endl;
return 0;
}