Check out example codes for "find all occurrences of a substring in a string c++". It will help you in understanding the concepts better.

Code Example 1

#include <string>
#include <iostream>

using namespace std;

int main()
{
    string s("hello hello");
    int count = 0;
    size_t nPos = s.find("hello", 0); // first occurrence
    while(nPos != string::npos)
    {
        count++;
        nPos = s.find("hello", nPos + 1);
    }

    cout << count;
};

Learn ReactJs, React Native from akashmittal.com