Chinaunix首页 | 论坛 | 博客
  • 博客访问: 607334
  • 博文数量: 138
  • 博客积分: 3067
  • 博客等级: 中校
  • 技术积分: 1565
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-21 12:44
文章分类

全部博文(138)

文章存档

2016年(5)

2014年(4)

2012年(1)

2011年(2)

2010年(10)

2009年(19)

2008年(97)

我的朋友

分类:

2008-07-23 19:40:29

 
I want to read someinfo from a file, and write someinfo into the file; there will be redundancy info in the file, if the length of writted info less than the length of original file info.
 
workaround:
open with std::fstream::in
then
open with std::fstream::trunc
 
 
 

std::fstream fs(fileName, std::fstream::in | std::fstream::out);
char cArray[256];
fs.getline(cArray,256);
fs.close();

std::fstream fsw(fileName, std::fstream::trunc | std::fstream::out);
//fs.seekg(std::ios_base::beg);

fsw.write(totalStr.c_str(), totalStr.size());
fsw.close();

阅读(1585) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~