fstream file("b.txt", ios::in|ios::out|ios::app);
mode
- ate - seek to the end of stream immediately after open,不会导致create属性
- app - seek to the end of stream before each write,Every output is appended at the end of file, 可造成out属性
- in 表示只读属性
- out 表可写属性+create属性
- in+out 表只读+可写属性(没有create属性)
- trunc
class default mode to parameter
ofstream ios::out | ios::trunc
ifstream ios::in
fstream ios::in | ios::out
//fstream file("b1.txt", fstream::in|fstream::out); do NOT create if no exist
fstream file("b1.txt", fstream::out); // create
file<<"s";
cout<<"s";
file.close();
}