开发者

spliting in c++ like what we do in c# [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicates:

How to split a string in C++?

Splitting a C++ std::string using tokens, e.g. “;”

think I have this string :

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

I want to split开发者_如何学Goting this string with ,

so I need a array of string like here :

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

what shoudl I do ?


This simple AXE parser will do it:

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


If you really don't want to code this on your own you can do a web search for "c++ tokenize string" and take, for example, a look here: CPPHOWTO

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜