分割字符串
来源:互联网 发布:jre 6u37 windows x64 编辑:程序博客网 时间:2024/06/18 07:56
#include <iostream>#include <sstream>#include <vector>using namespace std;std::vector<std::string> StringSplit(std::string src,std::string sp){while(src.find(sp)!=std::string::npos){int index=src.find(sp);src.replace(index,sp.length()," ");//把字串替换成空格}std::vector<std::string> vec;std::istringstream is(src);std::string subString="";while(is>>subString) //输入输出流{vec.push_back(subString);}return vec;}int main(){vector<string>vec;vec=StringSplit("123|432|456|7|88","|");copy(vec.begin(),vec.end(),ostream_iterator<string>(cout,"\n"));return 0;}
0 0
- 分割字符串
- 分割字符串
- 分割字符串
- 分割字符串
- 分割字符串
- 字符串分割
- 字符串分割
- 分割字符串
- 字符串分割
- 字符串分割
- 分割字符串
- 分割字符串
- 分割字符串
- 字符串分割
- 分割字符串
- 字符串分割
- 字符串分割
- 分割字符串
- 两分钟彻底让你明白Android Activity生命周期(图文)!
- mysql索引总结----mysql 索引类型以及创建
- Ubuntu下的屏幕录制
- Codeforces Round #353 (Div. 2) D. Tree Construction (二叉搜索树+set)
- spring BeanFactory 家族介绍
- 分割字符串
- Liblinphone 3.9.1中文--Modules--Controlling media parameters
- bind、apply、call之间的差异
- 测试初识
- Android使用HttpClient以Post、Get请求服务器发送数据的方式(普通和json)
- BZOJ2906 颜色
- python开发环境wingide的安装与破解
- 第七次编程作业
- leetcode-java-111. Minimum Depth of Binary Tree