-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,699
  • 7
  • 33
  • 70
srgnbcrk
  • 11
  • 2

2 Answers2

2

Frees all memory:

system("reboot");
Dellowar
  • 3,160
  • 1
  • 18
  • 37
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
  • 2
  • 12