using namespace std; #include #include #include void nomemory() { cerr << "Memoria esaurita: " << "impossibile allocare " << endl; exit(0); } int main () { const int mymax = 1024*1024*1024; for (int i=0;i<15;i++) { // "new (nothrow) ..." restituisce NULL // senza generare eccezioni se l'allocazione non va a buon fine char * p = new (nothrow) char [mymax]; if (p==NULL) nomemory(); for (int j=0;j