C++分割字符串函数封装
来源:互联网 发布:ysl高仿包包淘宝 编辑:程序博客网 时间:2024/06/08 10:01
#include <string>#include <vector>#include <iostream>#include <string.h>using namespace std;void split(const string& src, const string& separator, vector<string>& dest){ string str = src; string substring; string::size_type start = 0, index; do { index = str.find_first_of(separator,start); if (index != string::npos) { substring = str.substr(start,index-start); dest.push_back(substring); start = str.find_first_not_of(separator,index); if (start == string::npos) return; } }while(index != string::npos); //the last token substring = str.substr(start); dest.push_back(substring);}int main(){ vector<string>vStr; string str="aaa_bbb_ccc_ddd"; split(str,"_",vStr); cout<<str<<endl; for (int i=0;i<vStr.size();i++) { cout<<vStr[i]<<endl; } return 0;}
阅读全文
0 0
- C++分割字符串函数封装
- c 字符串分割函数
- 分割字符串函数split(C#)
- 分割字符串函数split(C#)
- c 分割字符串函数 split
- C语言字符串分割函数
- 两个常用C字符串分割函数
- C/C++分割字符串:strtok函数
- C中的一个字符串分割函数
- C语言分割字符串函数strtok
- C语言中的字符串分割函数
- C语言分割字符串strtok函数
- 标准C中strtok函数分割字符串
- 标准C中strtok函数分割字符串
- C 语言 分割字符串 strtok函数
- c中字符串分割函数strtok
- c语言字符串分割函数(strtok())
- C语言strtok()函数:字符串分割
- 双十一销量猛增 电商平台以外FIIL耳机开辟新路径
- 解决百度ueditor编辑器内容在jquery.validate中不验证问题
- 曾助力阿凡达、银河护卫队的这家公司,被mCube收了
- 10月份小程序观察 科技带动创新
- layui实现checkbox的目录树tree
- C++分割字符串函数封装
- android 仿ios右滑退出当前activity
- 操作符 ? 和 ??
- mysql group replication 单写模式 (single-primary mode) 搭建
- JQuery 对 Select option 的操作
- 移动端判断设备
- 十分钟搞定pandas
- HTML5+CSS3的响应式网页设计:自动适应屏幕宽度
- 观察者模式-《Head First 设计模式》第二章