Hi there,
I am writing a program which removes any word which appears more than one time after sorting a vector but i have been constantly facing the error that one of my variables has no data type despite me using auto.
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
void elidup(vector<string> &w)
{
sort(w.begin(), w.end());
auto end_unique = unique(w.begin(), w.end());
w.erase(end_unique, w.end());
}
int main()
{
string inp;
cout<<" Enter the vector in which duplicates are to be found. Input * to indicate that it is the end of the string"<<endl;
vector<string> word;
while(inp != "*")
// loop to enter the information in the vector
{
cin>>inp;
word.push_back(inp);
}
if(inp == "*")
// for erasing the duplicates and then print the vector
{
elidup(word);
for(int i = 0 ; i<(word.size() -1);i++)
cout<<word[i]<<" " ;
}
return 0;
}