- FStream The ability to read and write text
- ostream can only write to text
- IStream can only read text
Let 's take a look at the member functions of the Stream class libraryput (char c) outputs one characterWrite (const char * str,int N) outputs a string Get (char c) gets a charactergetline (char *buf,int n,char deline= ' \ n ') reads a line of characters the last parameter is the terminating flag characterRead (char *buf, int n) reads a number of characters Ios::in Read OnlyIos::out only outIos::app Appendios::ate at end of file when openIos::trunc If there is a file then empty, not exist then createios::binary opens in binary mode ------------------------------------the best way to profile is-----------------------------------writes written out of file stream pairs
int a;
string str;
istream file("123.txt",ios::in|ios::out);
file>>a;
file>>str;
//如果是写入的话
file<<a;
file<<str;
// 文件流一般是 遇到空格 或者 换行符 就会终止读取
From for notes (Wiz)
C + + file operation learning