0

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 splitting this string with ,

so I need a array of string like here :

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

what shoudl I do ?

Community
  • 1
  • 1
Ata
  • 12,126
  • 19
  • 63
  • 97

2 Answers2

0

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

Clemens
  • 1,744
  • 11
  • 20
0

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());
Gene Bushuyev
  • 5,512
  • 20
  • 19