您的位置:首页 > 其它

第16周-阅读程序4(2)

2016-06-17 17:33 155 查看
#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);
outfile.write (" sam",4);
outfile.close();
return 0;
}


运行结果:



知识点总结:

当我们写入一个文件,并要知道内置指针的当前位置时,用tellp()


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