什么是用C的strtok和strsep之间的差异 [英] What are the differences between strtok and strsep in C

查看:344
本文介绍了什么是用C的strtok和strsep之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能解释我什么差别有的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 and strtok_r is that if the input string contains more than one character from delimiter in a row strsep returns an empty string for each pair of characters from delimiter. This means that a program normally should test for strsep returning an empty string before processing it.

这篇关于什么是用C的strtok和strsep之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆