第十五周阅读项目3.(1)

来源:互联网 发布:tcpip协议栈 源码 编辑:程序博客网 时间:2024/05/23 00:01

问题及代码:

#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;}


运行结果:

 

学习总结:为什么输入五个字母显示的会是五个字节,难道不是7个字节么?求解答~~

0 0
原创粉丝点击