C++文件I/O
必须包含:头文件fstream
,包含文件输入类ifstream
和文件输出类ofstream
。
- 声明一个
ifsteam
/ofstream
对象,命名规则遵守变量命名。如ifstream fin
,ofstream fout
等。 - 将该对象与文件进行关联,常用方法为
open
方法。如in.open("input")
,out.open("output")
等。 - 之后像
cin
和cout
那样使用。 - 文件操作结束后,使用
close
方法关闭。
必须包含:头文件fstream
,包含文件输入类ifstream
和文件输出类ofstream
。
ifsteam
/ofstream
对象,命名规则遵守变量命名。如ifstream fin
,ofstream fout
等。open
方法。如in.open("input")
,out.open("output")
等。cin
和cout
那样使用。close
方法关闭。本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/907085.html
如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!