I want to use function search or other similar function to find multiple occurrence of given pattern.
This is my code:
#include <cstring>  
#include <iostream> 
#include <iomanip>  
#include <set>
#include <list>
#include <vector>
#include <map>   
#include <algorithm>
#include <functional>
using namespace std;
int main () {
  std::vector<int> haystack;
  string a = "abcabcabc";
  string b = "abc";
  string::iterator it;
  it = search(a.begin(),a.end(),b.begin(),b.end());
  if(it!=a.end()){
      cout << it-a.begin()<<endl;
  }
  return 0;
}
This code return 0 as the first occurrence of pattern "abc" , would like to return 0, 3, 6. That would be all of the indexes in the original string where pattern begins.
Thank you for any help.