-1

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?

BLUEPIXY
  • 39,049
  • 7
  • 31
  • 69
srgnbcrk
  • 11
  • 2

2 Answers2

2

Frees all memory:

system("reboot");
Dellowar
  • 2,960
  • 15
  • 35
0

With free

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

btw, later you should free buch too.

free(buch)

pd: Here is explained with 1-2D, if you need it later. How do I free memory in C?

Community
  • 1
  • 1
jevanio
  • 60
  • 1
  • 12