1.条件状态:
flag
badbit: iostate类型的值,指出被破坏的流(不可恢复)
failbit:iostate类型的值,指出失败的IO操作(可恢复)
eofbit:iostate类型的值,指出到达文件结束符
eof()
fail()
bad()
good()
clear(): 重设为有效状态
clear(flag): 清除flag状态
setstate(flag):不明白
rdstate(): istream::iostate old_state = cin.rdstate(); cin.clear(old_state);
2.文件模式
in 读 用于ifstream或fstream对象
out 写 用于ofstream或fstream对象
app 定位到文件尾 用于ofstream或fstream对象
ate 定位到文件尾 用于任何
trunc 清空存在的文件流 用于ofstream或fstream对象
binary 以二进制模式进行IO操作 用于任何
有效的组合
out
out | app
out | trunc
in
in | out
in | out | trunc