Do I need to free the strtok resulting string?

前端 未结 3 1383
遇见更好的自我
遇见更好的自我 2021-01-01 15:30

Or rather, how does strtok produce the string to which it\'s return value points? Does it allocate memory dynamically? I am asking because I am not sure if I need to free th

3条回答
  •  轮回少年
    2021-01-01 16:21

    strtok manipulates the string you pass in and returns a pointer to it, so no memory is allocated.

    Please consider using strsep or at least strtok_r to save you some headaches later.

提交回复
热议问题