title: repeated words from text file in c++
body: <p>This program finds words and erases all of them that are repeated in the text file. Here, I wrote this code to do so by inputting a specific word, but I want the program to find the kind of words by itself and in the result will show only the unrepeated words. I have tried by best but have failed. 
  Could you advise me to find a better way?</p>
  
  <pre><code>int main()
  {
     ifstream fin("name.txt");
     ofstream fout("result.txt");
     string word;
     string line;
  
     int pos;
     int ccount=0;;
  
     cout&lt;&lt;"Please input word:";
     cin&gt;&gt;word;
  
     while(getline(fin,line))
     {
         pos= 0;
         while(line.find(word,pos)!=string::npos)
         {
                 pos = line.find(word,pos);
                 line.erase(pos,word.length());
         }
  
          fout&lt;&lt;line&lt;&lt;endl;
     }
      fin.close();
      fout.close();
  }
  </code></pre>