计算机程序设计基础(第2版)乔林Qiaolin FOP Chapter 7.pptVIP

  • 44
  • 0
  • 约2.24万字
  • 约 90页
  • 2017-10-13 发布于浙江
  • 举报

计算机程序设计基础(第2版)乔林Qiaolin FOP Chapter 7.ppt

本章小结 使用 strtok 函数编写程序,将某个字符串分隔成多个子字符串输出 函数原型:char* strtok(char* token, const char* delimiters); 函数说明:返回字符串 token 中由字符串 delimiters 中各字符分隔的下一个子字符串(标记)。首次调用时,传递给 token 参数的是实际待分析的完整字符串,后续调用时简单传递 NULL 分隔符集:空格、Tab 键、回车、逗号、分号、句号 例:字符串“This is a sample string, which can be separated into 12 tokens.”可以分隔为 12 个子串,这些子串一般称为标记 字符串的分割示例 #include stdio.h #include string.h char string[] = This is a sample string, which can be separated into 12 tokens.; /* 子串分隔符集:空格、Tab键、回车、逗号、分号、句号 */ char delimiters[] = \t\n,;.; char *token; int main() { unsigned int n = 0; printf( Tokens:\n ); token = strtok( strin

文档评论(0)

1亿VIP精品文档

相关文档