什么是用C的strtok和strsep之间的差异 [英] What are the differences between strtok and strsep in C
问题描述
有人能解释我什么差别有的strtok之间()
和 strsep()
?
什么是他们的优势和劣势?
我为什么要挑一个比另外一个。
Could someone explain me what differences there are between strtok()
and strsep()
?
What are the advantages and disadvantages of them?
And why would I pick one over the other one.
推荐答案
从GNU C库手册 - 的查找令牌中的String :
From The GNU C Library manual - Finding Tokens in a String:
之间的一个区别 strsep
和 strtok_r
是,如果输入的字符串包含分隔多个字符的行 strsep
返回每个对字符分隔符从一个空字符串。这意味着,一个程序正常应该测试 strsep
处理之前返回一个空字符串。
One difference between
strsep
andstrtok_r
is that if the input string contains more than one character from delimiter in a rowstrsep
returns an empty string for each pair of characters from delimiter. This means that a program normally should test forstrsep
returning an empty string before processing it.
这篇关于什么是用C的strtok和strsep之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!