c_-_c_exception_handling:bad_alloc_exceptions
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.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1