when to carefully use free() to free up malloc() used memory?

后端 未结 3 1818
谎友^
谎友^ 2020-12-10 18:51

I read from many question here in SO and some other articles regarding free() function in c that frees the memory of unused variables. In my case, I have the following code

3条回答
  •  旧时难觅i
    2020-12-10 19:30

    strC is the return value of this function, so you don't call free(strC) inside the function itself. You need to free it outside the function, the time when this string is not used anymore.

提交回复
热议问题