fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. try
  7. {
  8. int* a = new int(0);
  9. std::cout << "allocated a " << &a << "\n";
  10. } catch (const std::bad_alloc &e)
  11. {
  12. std::cout << "bad alloc! " << e.what() << "\n";
  13. }
  14.  
  15. return 0;
  16. }
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
allocated a 0x7fffddd7f480