?? 11_99.cpp
字號:
#include<iostream.h>
#include<fstream.h>
void main()
{
char fname[20];
cout<<"輸入文件名:";
cin>>fname;
ifstream file(fname,ios::nocreate|ios::in);
try
{
if(file.fail())
//當文件不存在時,file.fail()返回真
throw "error!";
}
catch(char *s)
{
cout<<s<<fname<<"文件不存在!"<<endl;
return;
}
file.seekg(0,ios::end);
//此句意為將文件的讀指針移至文件末尾
cout<<fname<<"文件大小:"<<file.tellg()<<"Bytes"<<endl;
//tellg()函數返回當前文件指針的位置
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -