在c++中进行拆分,就像我们在c#中所做的那样
spliting in c++ like what we do in c#
可能的重复:
如何在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
相关文章:
- 为什么在运行时没有向我们提供有关分段错误的更多信息?
- 我们可以访问一个不存在的联盟的成员吗
- 如果编译的源代码是特定于它编译的硬件的,我们如何分发它
- 当使用透明的std函数对象时,我们还需要写空的尖括号吗
- 如何在C++中读取空格分隔的输入 当我们不知道输入的数量时
- 我们可以删除链表中静态内存中的节点吗
- 为什么我们要为avl树实现返回一个指向节点的指针,而不是void函数
- 当我们从/tp地址中添加/减去一个整数时会发生什么
- 当我们为(;;) 写作时,它做了什么?for 循环中的双分号有什么作用?
- int数据类型的指针指向的是什么,如果是一个类的私有数据成员,我们创建了该类的两个对象?
- 当我们进行一些操作时,应该使用什么'std::string'或'std::stringstream'?
- 我们可以将数据永久保存为数据结构吗?
- 为什么我们将单个或多维数组的大小声明为常量值?
- 为什么我们不能重复使用具有不同模板参数的别名模板标识符?
- 为什么当我们有常量引用时创建临时对象?
- 为什么我们再次从结构对象创建结构变量?
- 为什么我们不编写可以处理C++标识符的汇编器和链接器?
- 当返回类型声明为 ListNode 时,我们是否可以返回 false<T>*
- 我们是否需要为 C++ 中的多个函数初始化多个模板?
- 共享记忆:让我们谈谈它的特殊性