Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

find the second aperrence of a char in string c++

#include <iostream>
#include <boost/algorithm/string/find.hpp>

using namespace std;
using namespace boost;

int main() {

    string a = "The rain in Spain falls mainly on the plain";

    iterator_range<string::iterator> r = find_nth(a, "ain", 2);
    cout << std::distance(a.begin(), r.begin()) << endl;

    return 0;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #find #aperrence #char #string
ADD COMMENT
Topic
Name
2+7 =