第十六周阅读程序4(2)

问题及代码:

/*
*Copyright (c) 2016,烟台大学计算机学院
*All rights reserved.
*文件名称:zwj.cpp
*作    者:张伟晶
*完成日期:2016年6月17日
*版 本 号:v1.0
*
*问题描述:阅读程序
*输入描述:
*程序输出:
*/
#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;
}

运行结果:

知识点总结:

向文件中写入数据

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章