📄 f1505.cpp
字号:
//=====================================
// f1505.cpp
// 申请内存出错
//=====================================
#include<iostream>
#include<exception>
using namespace std;
//-------------------------------------
int main(){
try{
int* p = new int[1000000000]; // 将导致异常
p[1000000]=1000;
cout<<p[1000000]<<"\n";
}catch(bad_alloc){
cout<<"Bad Allocation...\n";
}
cout<<"end of programm.\n";
}//====================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -