#include "assert.h"
#include "string.h"
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int check_for_double(vector<string> * vocabulary){
vector<string> :: iterator temp;
int counter1=0;
int counter2=0;
for(vector<string> :: iterator i=vocabulary->begin();i!=vocabulary->end();i++ ){
cout<<" outer loop: "<<endl<<
" counter: "<<counter1<<endl<<
" value: "<< *i<<endl;
for(vector<string> :: iterator j=vocabulary->begin();j!=vocabulary->end();++j){
cout<<"inner loop\n";
cout<<"counter: "<<counter2<<endl<<
"value: "<< *j<<endl;
if((*i)==(*j)&&i!=j){
temp=j-1;
cout<<"erase occured**************************************8\n";
vocabulary->erase(j);
j=temp;
}
counter2++;
}
cout<<"got out from inner loop\n";
counter1++;
counter2=0;
}
return 1;
}
void check_for_double_test(){
vector<string> x;
x.push_back("hello");
x.push_back("hello");
x.push_back("world");
x.push_back("this");
x.push_back("this");
x.push_back("is");
x.push_back("jenia");
x.push_back("jenia");
check_for_double(&x);
assert(x[0]=="hello");
assert(x[1]=="world");
assert(x[2]=="this");
assert(x[3]=="is");
assert(x[4]=="jenia");
}
int main(){
//substring_test();
check_for_double_test();
}
//this gives me segmentation fault right at the end.
//how can i solve this problem