第十六周上机实践项目3(1):阅读程序

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


发布了129 篇原创文章 · 获赞 14 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_33757765/article/details/51722867
今日推荐