第十六周项目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()。
问题及代码:
/*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()。
相关文章推荐
- android 自定义控件(二)
- 程序员的成长和代码行数的关系
- 手机端的轮播效果
- mysql数据库操作语法大全
- Universal-Image-Loader,android-Volley,Picasso、Fresco和Glide五大Android开源组件加载网络图片的优缺点比较
- 差分约束系统
- 第十六周项目4:阅读下面的程序,指出其功能(1)
- JSP中的MIME
- 第十六周项目3:查看下面程序的输出结果,并解释为什么
- 从古希腊神话说起,讲讲英语里的偏旁部首
- Cocos2d-Lua之运算符
- 第十六周项目2:阅读并运行程序,分别用记事本和二进制文件阅读器阅读(2)
- sws_scale YV12转RGB24图像倒转问题
- Linux系统调用
- 实现判断一组数据是否为可逆素数
- 第十四周上机实践项目1(1):阅读程序
- Ubuntu16.04安装/卸载Atom
- 从2016/6/15日开始整理遇到的异常
- 两个对象比较重写equals
- 算法入门-打印蛇形数组