strtok() 是否可以安全使用 [英] Is strtok() safe to use
本文介绍了strtok() 是否可以安全使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我读了很多关于 strtok()
的负面信息,有人说它已经过时,有人说它不是线程安全的,等等.
I am reading a lot negative things about strtok()
, some say it is obsolete, some say it is not thread safe, etc.
那么真相是什么,我可以使用strtok()
吗?它是线程安全的吗?
So what is the truth, can I use strtok()
? and is it thread safe?
注意:我使用的是 Visual C++.
Note: I am using Visual C++.
推荐答案
你可以使用它,它是标准库的一部分.
You can use it, it's a part of the standard library.
它使用由函数的所有用户共享的内部存储,所以不它不是线程安全的.
It uses internal storage that is shared across all users of the function, so no it's not thread-safe.
它还修改你交给它的字符串,这很可怕.
It also modifies the string you hand to it, which is quite scary.
在大多数情况下,我不建议使用它.
I would not recommend using it, in most cases.
这篇关于strtok() 是否可以安全使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文