This is a beginner question but I learned programming with c# and I am now moving to c++ and now that I am working with pointers, I know that I have to free them from memory when I'm done with them but when the program is closed are they removed from the memory or do they stay there?
When your program ends, all the memory it used (whether dynamically allocated or not) is returned to the operating system. It doesn't matter if it's a C program, a C++ program, a C# program, or any other kind of program you might be writing.
Now, just because the OS will reclaim the memory doesn't mean you can be cavalier about memory management. While your program runs, you should try to take care of freeing any memory you're done with. Not doing so will cause "memory leaks", and those can certainly affect your program and the system it's running on, at least while your program is running.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With