- /*
- *Copyright(c) 2016.烟台大学计算机与控制工程学院
- *ALL rights reserved.
- *文件名称:test.cpp
- *作者:李落才
- *完成日期:2016年6月15
- *问题描述:阅读下面的程序,指出其功能,体会seekg()、tellg()等函数的功能及其用法
- */
- #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;
- }