指定分割符,分割字符串并存放到 list 中
来源:互联网 发布:java解析excel数据 编辑:程序博客网 时间:2024/06/06 19:02
#include <string>
#include <sstream>
#include <list>
#include <algorithm>
using namespace std;
//string ProName = "1.exe/2.exe/3.exe"
//拆分为1.exe, 2.exe, 3.exe, 放到 list<string> 里面
void strConvert(const string str, list<string> &strList)
{
if (str.empty()) return;
strList.clear();
replace((char*)str.c_str(), (char*)(str.c_str()+str.length()), '//', ' ');
stringstream ss(str);
string tmpStr;
do
{
ss >> tmpStr;
strList.push_back(tmpStr);
} while(ss.good());
}
这里的分割符号为 “/”,使用的时候可以更换成其他符号,比如 “|”
#include <sstream>
#include <list>
#include <algorithm>
using namespace std;
//string ProName = "1.exe/2.exe/3.exe"
//拆分为1.exe, 2.exe, 3.exe, 放到 list<string> 里面
void strConvert(const string str, list<string> &strList)
{
if (str.empty()) return;
strList.clear();
replace((char*)str.c_str(), (char*)(str.c_str()+str.length()), '//', ' ');
stringstream ss(str);
string tmpStr;
do
{
ss >> tmpStr;
strList.push_back(tmpStr);
} while(ss.good());
}
这里的分割符号为 “/”,使用的时候可以更换成其他符号,比如 “|”
- 指定分割符,分割字符串并存放到 list 中
- 以指定分隔符分割字符串存储到vector中
- MFC中按指定分隔符分割CString字符串
- C++中使用指定字符分割字符串
- 指定符号分割字符串
- 获取以指定分割符分割的字符串
- shell 使用指定的分割符来分割字符串
- 用指定的分割符解析字符串
- 字符串以指定符号分割
- 根据指定要求分割字符串
- awk指定分割符
- c#中字符串分割
- c#中字符串分割
- .net中字符串分割
- c#中字符串分割
- C++ 字符串分割,分割到vector中
- JavaScript拆分字符串并将分割的数据放到数组中
- C++ 用指定字符串分割字符串
- Lucene的QueryParser搜索时出现ParseException
- UTM投影正转算法实现
- 计算机处理图像信息的三个领域
- 在 ASP.NET 中使用 HTTP 模块实现 Intercepting Filter
- SQL Server存储过程和参数示例
- 指定分割符,分割字符串并存放到 list 中
- 《Win32多线程程序设计》学习笔记---(1)
- Servlet
- 代替 count(*) 的更有效率的办法
- mysql非rpm安装版本的安装过程
- 图象处理部分文章列表
- Exchange 2003 设计与体系结构
- 安装oracle时错误OUI-25031
- this()方法与this属性