strtok函数的作用是分割字符串。
 
函数原型:
char *strtok(char *str1, char *str2);  
返回在参数1中用参数2进行分割得到的字符串。
 
这句话可能比较绕口,具体看例子,比较容易理解。
// strtok_test.c 
#include <string.h>
#include <stdio.h>

int main()
{
  char s[] = "Iloveyou";
  char *p;

  p = strtok(s, "o");

  do {
    printf("%s\n", p);
  } while(p = strtok(NULL, "o"));
  // must be NULL, if you want to get the next token spilt by 2nd parameter

  return 0;
}




相关文章:

  • 2022-12-23
  • 2022-02-24
  • 2022-02-13
  • 2022-12-23
  • 2021-06-17
  • 2021-09-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-25
  • 2021-07-01
  • 2022-12-23
  • 2021-10-17
  • 2021-08-19
  • 2022-12-23
相关资源
相似解决方案