📄 13.10.cpp
字号:
#include <iostream.h>
#include <string.h>
#include <fstream.h>
#include <stdlib.h>
class FileExcept
{
public:
FileExcept(char *s)
{
strcpy(mag,s);
// cout<<mag<<endl;
}
char *returnExpt()
{ return mag; }
private:
char mag[80];
};
void main()
{
fstream infile("abwac.txt",ios::in);
FileExcept e("Can't open file!");
try
{
if(!infile)
throw e;
}
catch(FileExcept &e)
{
cout<<"The exception is caught."<<e.returnExpt()<<endl;
abort();
}
char str[80];
while(!infile.eof())
{
infile.getline(str,sizeof(str));
cout<<str<<endl;
}
infile.close();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -