问题及代码:
/*copyright(c)2016.烟台大学计算机学院
* All rights reserved,
* 文件名称:text.Cpp
* 作者:吴敬超
* 完成日期:2016年6月13日
* 版本号:codeblock
*
* 问题描述:
* 输入描述:
* 程序输出: 输出结果
*/
#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-1) << " bytes.\n";
return 0;
}
运行结果: