computer 版 (精华区)
发信人: remember (学海无涯·回头是岸), 信区: program
标 题: 关于文件
发信站: 听涛站 (2001年12月09日03:32:48 星期天), 站内信件
我好困啊~~~~
发现说漏了文件操作,补上一篇吧。不过就从简了。
标准库,头文件fstream,命名空间std。
提供读文件类ifstream。构造函数需要一个字串性参数,
标明需要打开的文件。读文件提供了>>运算符。
例子:
#include <fstream>
using namespace std;
int main() {
ifstream infile("test.txt");
char c;
if (!infile) {
//出错处理
}else{
while(infile>>c)
cout<<c;
}
}
--
洛阳亲友如相问 一片冰心在玉壶
※ 来源:·听涛站 tingtao.dhs.org·[FROM: 匿名天使的家]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:1.821毫秒