strdup() - what does it do in C?

前端 未结 10 2287
情话喂你
情话喂你 2020-11-21 23:22

What is the purpose of the strdup() function in C?

10条回答
  •  失恋的感觉
    2020-11-22 00:05

    It makes a duplicate copy of the string passed in by running a malloc and strcpy of the string passed in. The malloc'ed buffer is returned to the caller, hence the need to run free on the return value.

提交回复
热议问题