Freeing memory which has been allocated to an array of char pointers (strings). Do I have to free each string or just the “main” pointer?

后端 未结 4 923
春和景丽
春和景丽 2021-02-15 11:26

I have a function that takes a pointer to a char ** and fills it with strings (an array of strings I guess). *list_of_strings* is allocated memory inside the function.



        
4条回答
  •  一整个雨季
    2021-02-15 12:02

    You need to iterate over list and call free() on every array member. Then free the array.

提交回复
热议问题