Need a project done?

C++ Programming Developer

Search This Blog

Exception bad_alloc C++


1:  #include <iostream>  
2:  using namespace std;  
3:  #include <string>  
4:    
5:  int main(){  
6:       int *list[100];  
7:    
8:       try{  
9:            for (int i = 0; i<100; i++){  
10:                 list[i] = new int[50000000];  
11:                 cout << "Created List[" << i << "] of 50000000 components." << endl;  
12:            }  
13:       }  
14:       catch(bad_alloc be){  
15:            cout << "In the bad_alloc catch bloc: " << be.what() << endl;  
16:       }  
17:       return 0;  
18:  }  

No comments:

Post a Comment

"Don't let anyone ever make you feel like you don't deserve what you want."