【问题标题】:How can I free allocated Memory?如何释放分配的内存?
【发布时间】:2016-12-08 17:12:24
【问题描述】:

我有一个作业,我有一些问题

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

我怎样才能释放这个分配的内存?

【问题讨论】:

  • free(buch->title);
  • free(buch->author);
  • 这不是做作业的网站。如果这是你的作业,那么可以肯定的是,在你的材料中某处写着如何释放内存。自己做作业

标签: c arrays malloc free


【解决方案1】:

释放所有内存:

system("reboot");

【讨论】:

    【解决方案2】:

    免费

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

    顺便说一句,稍后你也应该释放 buch。

    free(buch)
    

    pd:这里用1-2D解释,以后需要的话。 How do I free memory in C?

    【讨论】:

      猜你喜欢
      • 2020-11-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-09
      • 1970-01-01
      • 2011-05-13
      • 2015-07-30
      相关资源
      最近更新 更多