6.17 阅读程序 理解seekg() tellg()的用法
来源:互联网 发布:怎样网络上发布小说 编辑:程序博客网 时间:2024/05/24 01:38
#include<iostream>
#include <fstream>
using namespace std;
const char * filename = "a.txt";
int main ()
{
long l,m;
ifstream file (filename, ios::in|ios::binary);
l = file.tellg();
file.seekg (0, ios::end);
m = file.tellg();
file.close();
cout << "size of " << filename;
cout << " is " << (m-l) << " bytes.\n";
return 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;
}
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
fstream outfile,infile;
outfile.open("data.txt",ios::out);
for (int i=0;i<26;i++)
outfile<<(char)('A'+i);
outfile.close();
infile.open("data.txt",ios::in);
char ch;
infile.seekg(6,ios::beg);
if(infile.get(ch))
cout<<ch;
infile.seekg(8,ios::beg);
if(infile.get(ch))
cout<<ch;
infile.seekg(-8,ios::end);
if(infile.get(ch))
cout<<ch;
cout<<endl;
infile.close();
return 0;
}
- 6.17 阅读程序 理解seekg() tellg()的用法
- 第十七周阅读程序三----seekg()tellg()
- 第十七周阅读程序四----seekg()tellg()
- seekg() 与 tellg() 的用法及功能
- seekg()与tellg()用法
- 第14周-阅读项目3-seekg()、tellg()等函数的功能及其用法
- seekg()与tellg()用法详解
- seekg()/seekp()与tellg()/tellp()的用法详解
- seekg()/seekp()与tellg()/tellp()的用法详解 .
- seekg()/seekp()与tellg()/tellp()的用法详解
- seekg()/seekp()与tellg()/tellp()的用法详解
- seekg()/seekp()与tellg()/tellp()的用法详解
- seekg()/seekp()与tellg()/tellp()的用法详解
- seekg()/seekp()与tellg()/tellp()的用法详解
- seekg()/seekp()与tellg()/tellp()的用法详解
- C++流 rdbuf()以及seekg()/seekp()与tellg()/tellp()的用法详解
- C++流 rdbuf()以及seekg()/seekp()与tellg()/tellp()的用法详解
- C++:fstream类中seekg()/seekp()与tellg()/tellp()的用法详解
- vvvo--test
- 第十一周项目 3 立体类族共有的抽象类
- hbase shell 常用命令
- 我——成为真实的自己
- 关于ad所用端口
- 6.17 阅读程序 理解seekg() tellg()的用法
- 欢迎使用CSDN-markdown编辑器
- 用二进制文件处理学生信息
- OpenCV的IplImage与我的CHYBitmap的互转
- 第十五周程序阅读三
- 第15周 程序阅读-二进制文件及文件的读取4
- HDU 5039 Hilarity(dfs序+线段树)
- 我——成为一个人,不再迷茫
- 每天一个linux命令(23):Linux 目录结构