In this code,I use free to free the memory.But I still getting output.How does those output coming? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

In this code,I use free to free the memory.But I still getting output.How does those output coming?

Free Function in C https://sololearn.com/compiler-playground/cUl82451OWKB/?ref=app

7th Feb 2024, 10:50 AM
Yogeshwaran P
Yogeshwaran P - avatar
2 Antworten
+ 4
Yogeshwaran P after you free a block of memory it can remain untouched for awhile. It depends on when the OS happens to need that memory for the next allocation. In this case, the first record of recs does get overwritten immediately, but the second record remains. Beware that the code has memory leaks because it does not free the memories from the malloc in line 20 before freeing recs.
7th Feb 2024, 11:36 AM
Brian
Brian - avatar
7th Feb 2024, 12:29 PM
Bob_Li
Bob_Li - avatar