0

Is it possible to specify the starting position for the string being searched with std::find?

something like

std::string str = "kjsdfsdxksldfjsldjf";
int position = str.find("x", 2);

So it will start searching from index 2? I have a recursive function and need to specify the next starting pos (I'm not interested in searching every occurrence of the character with while/for loop)

GodIsGood
  • 79
  • 1
  • 6

1 Answers1

4

Yes according to this http://en.cppreference.com/w/cpp/string/basic_string/find second argument is position of the first character in the string to be considered in the search.

Izaya
  • 409
  • 3
  • 6