字符串分割函数——C语言
2017-03-18 19:58
253 查看
函数定义:char * strtok ( char * str, const char * delimiters );
参数说明:str即为要分解的字符串,delimiters为要分割的字符串。
返回值:从str的头部开始的一个个被分割的字串,没有分割的子串的时候,返回NULL。
具体网址:
http://www.cplusplus.com/reference/cstring/strtok/?kw=strtok(c++plusplus)
具体案例:
运行结果:
参数说明:str即为要分解的字符串,delimiters为要分割的字符串。
返回值:从str的头部开始的一个个被分割的字串,没有分割的子串的时候,返回NULL。
具体网址:
http://www.cplusplus.com/reference/cstring/strtok/?kw=strtok(c++plusplus)
具体案例:
#include <cstdio> #include <cstring>//需要的头文件 int main() { char s[]="helloworld,2,nice,0,ok,0,yes,0,one,1,two,2,three,0,four,0"; const char *delim=","; char *p; p=strtok(s,delim); while(p) { printf("%s ",p); p=strtok(NULL,delim); } printf("\n"); }
运行结果:
相关文章推荐
- C语言strtok()函数:字符串分割
- c语言字符串分割函数mysplit,可处理多个空格
- C语言strtok()函数:字符串分割
- C语言中strtok函数进行分割字符串!
- C语言strtok()函数:字符串分割
- C语言字符串分割函数split实现
- C语言strtok()函数:字符串分割
- C语言中的字符串分割函数
- C语言strtok()函数:分割字符串(自己实现strtok)
- C语言:使用strtok()函数分割字符串
- C语言:使用strtok_s()函数简单分割字符串
- C语言sscanf()函数:从字符串中读取指定格式的数据&&C语言strtok()函数:字符串分割
- C语言strtok()函数:字符串分割
- C语言strtok()函数:字符串分割
- C语言中strtok函数进行分割字符串!
- C语言中的字符串分割函数strtok的用法
- AfxExtractSubString分割字符串的函数
- vc分割字符串的函数
- C语言中操作字符串的一些函数源代码
- 写的一个简单的分割字符串的函数(附原码)