第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;
}
运行结果:
/*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;
}
运行结果:
相关文章推荐
- 洗牌
- Hibernate之Session merge与update方法
- 线性模型学习笔记
- Nginx下Redmine配置
- Magento前端开发指南(二)
- android ListView详解,你不知道的事 (后附焦点解决方法)
- Swift - 各种手势检测大全(UIGestureRecognizer及其子类)
- MNIST 可视化
- EF--Codefirst 加密数据库连接字符串
- VS code golang 开发环境搭建
- Android 开源框架 反编译工具
- ACPI 主要Table作用
- linux用户及管理权限
- textfiled值得拥有
- Linux开发环境搭建之Samba服务器配置
- 如何将一个项目导出成API文档
- 图结构练习——BFS——从起始点到目标点的最短步数
- 使用RecyclerView实现滑动添加、滑动删除,以及瀑布流、ListView、GridView的转换
- bootstrapTable跨域问题
- windows下安装rabbitmq的php扩展amqp