How does strtok() split the string into tokens in C?

前端 未结 15 2042
陌清茗
陌清茗 2020-11-22 14:48

Please explain to me the working of strtok() function. The manual says it breaks the string into tokens. I am unable to understand from the manual what it actua

15条回答
  •  深忆病人
    2020-11-22 15:32

    The first time you call it, you provide the string to tokenize to strtok. And then, to get the following tokens, you just give NULL to that function, as long as it returns a non NULL pointer.

    The strtok function records the string you first provided when you call it. (Which is really dangerous for multi-thread applications)

提交回复
热议问题