If i declare something on the heap like char *a=new char[1000] and the main program stops what will happen with that allocated memory if there is no delete[] call? It remains on the heap or is automatic deallocated?
4 Answers
What the C++ standard specifies "ends" shortly after you return from main() - it does explain that global objects are destroyed at some point after this, atexit() and some other "we're quitting" level functions also get run after main returns. But what happens to the memory that your program lives in is not specified by the C++ standard. The same applies to the contents of the heap.
It is up to the OS to clear up the application, if there is an OS in the system (C++ doesn't specify that you have to have an OS either).
ahere. You allocate objects on the heap. Well, formally, the "free store", but nobody calls it that.