#include #include #include char* alloc_mem(int how_much) { char *p= NULL; try { p= new char[how_much]; } catch (bad_alloc) { cerr << "memory allocation failed- couldn't allocate " << how_much << " characters!" << endl; exit(-1); } return p; } int main() { int many, i; char *m; cout << "how many times? "; cin >> many; for (i = 0; i < many; i++) m= alloc_mem(5000000); cout << "successful" << endl; return 0; }