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
2 Answers
+ 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.
+ 3
maybe this way:
https://sololearn.com/compiler-playground/c898rWZrFd4C/?ref=app