在c++中进行拆分,就像我们在c#中所做的那样

spliting in c++ like what we do in c#

本文关键字:我们 c++ 拆分      更新时间:2023-10-16

可能的重复:
如何在C++中拆分字符串
使用标记拆分C++std::字符串,例如“rdquo;

我想我有这个字符串:

string a = "hello,usa,one,good,bad";

我想用拆分这个字符串

所以我需要一个字符串数组,如下所示:

string *a ; a = { hello , usa , one , good , bad } 

我该怎么办?

这个简单的AXE解析器可以做到这一点:

std::vector<std::string> strings;
auto split = *(*(axe::r_any() - ',') >> e_push_back(strings));
split(a.begin(), a.end());

如果你真的不想自己编写代码,你可以在网上搜索"c++标记字符串",例如,看看这里:CPPHOWO