15-4.cpp

来自「为初学者提供的最佳的C++程序设计源程序库」· C++ 代码 · 共 23 行

CPP
23
字号

#include<iostream.h>
#include<fstream.h>
void main()
{
  char fn[20];
  cout<<"文件名";
  cin>>fn;
  ifstream file(fn,ios::nocreate|ios::in);
  try
  {
    if(file.fail())
		throw"error";
  }
  catch (char *s)
  {
    cout<<"不存在文件"<<fn<<endl;
	return ;
  };
  file.seekg(0,ios::end);
  cout<<fn<<"文件大小:"<<file.tellg()<<"Bytes"<<endl;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?