#include <iostream>
#include <vector>
using namespace std;
bool foo(const string&str,const string&prov,size_t& it)
{
size_t iter = 1;
for (auto i = it; i < str.length(); i++)
{
if (str != prov[iter])
{
it = i; return false;
}
if (prov.length()-1 == iter)
{
it = i; return true;
}
iter++;
}
return false;
}
int main()
{
vector<size_t>index;
string str = "String is wery usefull class. Another class not one.";
string f = "class";
size_t temp{};
for (size_t i = 0; i < str.length(); i++)
{
if (str == f[0])
{
temp = i;
if (foo(str, f, ++i)) index.push_back(temp);
}
}
if (index.size())
{
cout << "Find " << index.size() << " entries at positions:\n";
for (auto& i : index) cout << i << " ";
}
//end of programm
}