返回信息流#include<fstream>
#include<iostream>
using namespace std;
int main()
{
ifstream inf;
inf.open("text.txt",ios::in);
if(inf.fail()){
cout<<"open file fail!";
return -1;
}
char ch;
while(inf.get(ch))
{
cout<<ch;
}
cout<<"Done.\n";
inf.close();
return 0;
}
运行时什么也不显示,是怎么回事呢?
这是一条镜像帖。来源:北邮人论坛 / cpp / #42519同步于 2010/8/19
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
【求助】:C++文件读取
lhfx
2010/8/19镜像同步22 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
测试了一下,能正常运行
【 在 lhfx 的大作中提到: 】
: #include<fstream>
: #include<iostream>
: using namespace std;
: ...................
【 在 hanson2005 的大作中提到: 】
: lz的编译环境呢?
: --
: 睡姿不对,换个重来。
: ...................
vs2008。。。
【 在 gootyking 的大作中提到: 】
: 我怎么练文件都打不开。。呃。。
: 【 在 lhfx (寒冰) 的大作中提到: 】
: : 就一行英文字符都不行。。。
: ...................
打开失败??