Why am I being asked to set pointer to Null after freeing?

when an application is complete and closed, all memory associated with it it freed by the operating system kernel

one cannot do any harm to a computer by freeing or failing to free memory within an application, except if there's a big enough memory leak, you could have your application take up enough space to slow down or possibly crash the operating system. though that generally does nothing more than forcing you to reboot, it shouldn't permanently harm anything

pointers don't get freed, memory does. a pointer is just a variable that contains the address of something. if it happens to be a dynamically created piece of memory, either from new or malloc, then freeing it should be done when it's no longer used

a NULL pointer is just a variable that contains a NULL rather than a valid piece of memory, it's a value that basically means "no valid memory location".

/r/learnprogramming Thread