Thread umwandeln string in array (9 answers)
Opened by Gast at 2007-05-16 19:38

esskar
 2007-06-11 14:26
#11560 #11560
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
und wenn man eh schon die StdLib benutzt, z.b. auch so

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
std::vector<std::string> StringSplit(const std::string & str, const std::string & pattern) {
std::vector<std::string> retval;
std::string work = str;

int pos;
while((pos = work.find(pattern)) != std::string::npos) {
std::string item = work.substr(0, pos);
retval.push_back(item);

work = work.substr(pos + pattern.length());
}

if(work != "")
retval.push_back(work);

return retval;
}

View full thread umwandeln string in array