【C++】字符串分割 strtok_s

时间:2014-05-04 17:43:24   收藏:0   阅读:256

 char str[] = "now # is the time for all # good men to come to the # aid of their country"; //缓冲块首地址
 char delims[] = "#";      //缓冲块中单词之间的分隔符
 char *strToken = nullptr;              //指向将被处理的单词
 char *next_token = nullptr;            //保存缓冲块中下一个将被读取的单词的位置

 

 strToken = strtok_s( str, delims,&next_token);

 

 while( strToken  != NULL ) {
  printf( "result is \"%s\"\n", strToken  );
  strToken  = strtok_s( nullptr, delims,&next_token);
 }

【C++】字符串分割 strtok_s,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!