您的位置:首页 > 其它

第十六周项目4:阅读下面的程序,指出其功能(2)

2016-06-15 19:45 260 查看

问题及代码:

/*Copyright (c)2016,烟台大学计算机与控制工程学院
*All rights reserved.
*文件名称:main.cpp
*作 者:崔青青
*完成日期:2016年6月13日
*版 本 号:v1.0
*问题描述:
*输入描述:无
*输出描述:无
*/

#include <iostream>
#include<fstream>
#include<cstring>
#include<cstdlib>
using namespace std;
const char*filename="a.txt";
int main()
{
long pos;
ofstream outfile;
outfile.open("test.txt");
outfile.write("This is an apple ",16);
pos=outfile.tellp();
outfile.seekp(pos-7);
outfile.write("sam",4);
outfile.close();
return 0;
}

知识点总结:

open()和write()函数都是outfile的成员函数,对输入流操作:seekg()与tellg()

对输出流操作:seekp()与tellp()。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: