LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 447|回复: 0

文件为空?

[复制链接]
发表于 2004-6-5 20:54:52 | 显示全部楼层 |阅读模式
#include <iostream>
#include <fstream>
using namespace std;
main()
{
//fstream inout("D:\\xgg.txt",ios::in|ios::app,filebuf:penprotread|filebuf::sh_write);
// fstream inout("D:\abc.txt",ios_base::in);
//fstream str;
        int cnt=0;
char ch;
fstream inout("D:\\xgg.txt",ios::in|ios::app);

//str.open("D:\\xgg.txt",ios::in|ios::app);
// if(!inout.is_open())
if(!inout)
  cout<<"begin fail"<<endl;


inout.seekg(0);
while(inout.get(ch))
{
  cout.put(ch);
  cnt++;
  if(ch=='\n')
  {
  ios::pos_type mark=inout.tellg();
   //int mark=inout.tellg();
   inout<<cnt<<' ';
   inout.seekg(mark);
   //file://inout.put(' ');
  }
}

inout.clear();
inout<<cnt<<endl;
cout<<"cnt : "<<cnt<<endl;
return 0;

}

但是inout居然为空
为什么会这样
怎么改?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表