⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 13.10.cpp

📁 这是C++的一部分练习程序!对初学者有一定的帮助作用。
💻 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 + -