您的位置:首页 > 其它

第16周项目——文件阅读8

2016-06-21 13:16 274 查看
问题及代码:

/*copyright(c)2016.烟台大学计算机学院
* All rights reserved,
* 文件名称:text.Cpp
* 作者:李一波
* 完成日期:2016年6月21日
* 版本号:codeblocks
*
* 问题描述:
* 输入描述:
* 程序输出:
*/
#include <fstream>
using namespace std;
int main ()
{
long pos;
ofstream outfile;
outfile.open ("test.txt");
outfile.write ("This is an apple",16);
pos=outfile.tellp();
outfile.seekp (pos-7);//把当前指针向前移动7个位置
outfile.write (" sam",4);//把 sam这占4个字节的写入this is an apple 并且把其中的字节取代
outfile.close();
return 0;
}

运行结果:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: