C语言之分割字符串
来源:互联网 发布:阿里云客服投诉电话 编辑:程序博客网 时间:2024/05/18 00:11
The strtok() function returns a pointer to the next “token” in str1, where str2 contains the delimiters that determine the token. strtok() returns NULL if no token is found. In order to convert a string to tokens, the first call to strtok() should have str1 point to the string to be tokenized. All calls after this should have str1 beNULL.
For example:
char str[] = "now # is the time for all # good men to come to the # aid of their country"; char delims[] = "#"; char *result = NULL; result = strtok( str, delims ); while( result != NULL ) { printf( "result is \"%s\"\n", result ); result = strtok( NULL, delims ); }
The above code will display the following output:
result is "now " result is " is the time for all " result is " good men to come to the " result is " aid of their country"
这个函数跟编译器中的词法分析很向,在以后的文本处理中,会解决很多问题。看来我有必要系统的学习下C的库函数,而不仅仅是死扎在语法和一些算法技巧上面。这样在平常的工作中才能事半功倍。
使用这个函数,形如下面得配置文件就非常容易解析:
id1 value1 value2 value3
id2 value1 value2 value3
…
0 0
- C语言之分割字符串
- C语言字符串分割
- C语言分割字符串
- C 语言分割字符串
- Linux下C语言字符串操作之分割字符串总结
- C语言字符串分割函数
- c语言实现字符串分割
- c语言的字符串分割
- c语言实现字符串分割
- C语言的字符串分割
- C语言字符串的分割
- C语言 strtok 字符串分割
- C语言字符串的分割
- C语言标准字符串分割
- c库函数之分割字符串
- C 语言使用特定字符分割字符串
- C语言分割字符串函数strtok
- 用C语言来分割字符串
- 用方法论学Java之——第一章:Java 历史
- Spring学习历程---Spring学习前必学的知识之反射机制
- hdu 1226 超级密码 广搜
- Hibernate (9)双向多对一cascade属性
- 认识变量:(JS)
- C语言之分割字符串
- mysql乐观锁总结
- 16. 数据类型
- bestcoder-Fxx and string
- 5分钟理解JS中的this关键字
- 普通web项目转换为Maven, 解决 Field 'SYSTEM_PROPERTIES_MODE_ENVIRONMENT' not found in class
- 字节,半字对齐,字对齐方式
- IntelliJ IDEA中怎么查看方法说明
- lca(最近公共祖先)倍增模板【pascal】