简体   繁体   English

如何释放已分配的内存?

[英]How can I free allocated Memory?

i have a homework and i have some problems 我有作业,但有一些问题

buch->title = malloc(MAX_STR* sizeof(char));
buch->author = malloc(MAX_STR* sizeof(char));

how can i free this allocated memory? 我如何释放分配的内存?

释放所有内存:

system("reboot");

With free 有免费

free(buch->title)
free(buch->author)

btw, later you should free buch too. 顺便说一句,以后您也应该释放buch。

free(buch)

pd: Here is explained with 1-2D, if you need it later. pd:如果以后需要,这里用1-2D进行说明。 How do I free memory in C? 如何释放C中的内存?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM