There is a textfile containing names:
Jack Sparrow
David Linch
Jack Sparrow
Umble Gamble
Lee Sion
Truman Bruman
Lee Sion
I have tried to remove duplicates from it using <set>, but the problem is that it sorts automatically. I want to do it without being sorted.
Here is my code:
int main()
{
    string name;
    set <string> nameList;
    char fileName[50];
    cout << "Please Enter file name: ";
    cin >> fileName;
    ifstream read(fileName);
    if(!read){
        cout << "File not found!" << endl;
        return -1;
    }
    while(read.good()){
         if(!read.eof()){
              copy(istream_iterator<string>(read),istream_iterator<string>(),inserter(nameList,nameList.end()));
    }
    }
    read.close();
        cout<<endl;
        copy(nameList.begin(),nameList.end(),ostream_iterator<string>(cout," "));
        cout<<endl;
    return 0;
}
 
    