1std::string Find(std::string const& palabra, std::string const& delim, int & init)
2{
3 int end = palabra.find(delim, prev);
4 std::string toReturn = palabra.substr(init, end - init);
5 init = end;
6 return toReturn;
7}
8
9std::string s = "Hola-perro-Cosa";
10int init = 0;
11std::string string1 = Find(s, "-", init);
12std::string string2 = Find(s, "-", init);
13std::string string3 = Find(s, "-", init);
14
1std::string s = "Hola-perro-Cosa";
2int init = 0;
3int end = 0;
4while( end = s.find("-", init), end >= 0 )
5{
6 std::cout << s.substr(init, end - init) << '\n';
7 init = end + 1;
8}
9std::cout << s.substr(init);
10