c_-_c_exception_handling:bad_alloc_exceptions
This is an old revision of the document!
C - C++ Exception Handling - bad_alloc Exceptions
#include <iostream> using std::cout; using std::bad_alloc; int main() { int* p[10]; try { for ( int i = 0; i < 10; i++ ) { p[ i ] = new int[2]; cout << "\nAllocated successfully"; } } catch ( bad_alloc &memoryAllocationException ) { cout << "Bad allocation " << memoryAllocationException.what() ; } return 0; }
c_-_c_exception_handling/bad_alloc_exceptions.1507804900.txt.gz · Last modified: 2020/07/15 09:30 (external edit)