c 2b 2b recorrer string

Solutions on MaxInterview for c 2b 2b recorrer string by the best coders in the world

showing results for - "c 2b 2b recorrer string"
Alejandro
12 Nov 2017
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
Tiphaine
05 Nov 2018
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