title: C++ Finding Anagrams in words
body: <p>I'm working on a program that looks at whether or not a particular word is an anagram using <code>std:count</code> however, I don't think my function logic is correct and I cannot seem to figure it out. </p>
  
  <p>Assume there are the following words in the file:</p>
  
  <pre><code>Evil
  Vile
  Veil  
  Live
  </code></pre>
  
  <p>My code is as follows:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;fstream&gt;
  #include &lt;map&gt;
  using namespace std;
  
  struct Compare {
  std::string str;
  Compare(const std::string&amp; str) : str(str) {}
  };
  
  bool operator==(const std::pair&lt;int, std::string&gt;&amp;p, const Compare&amp; c) {
  return c.str == p.second;
  }
     bool operator==(const Compare&amp; c, const std::pair&lt;int, std::string&gt;&amp;p) {
     return c.str == p.second;
  }
  
  std::vector&lt;std::string&gt; readInput(ifstream&amp; file)
  {
  std::vector&lt;std::string&gt; temp;
  
  string word;
  
  while (file &gt;&gt; word)
  {
      temp.push_back(word);
  }
  std::sort(temp.begin(), temp.end());
  
  return temp;
  }
  
  int main(int argc, char *argv[]) {  
  
  string file = "testing.txt";
  ifstream ss(file.c_str());
  
  if(!ss.is_open())
  {
      cerr &lt;&lt; "Cannot open the text file";
  }
  
  std::vector&lt;std::string&gt; words = readInput(ss);
  
  std::map&lt;int, std::string&gt; wordsMap; 
  
  //std::map&lt;std::string value, int key&gt; values; 
  
  for(unsigned i=0; (i &lt; words.size()); i++)
  {
      wordsMap[i] = words[i];
  }
  
  
  int count = std::count(wordsMap.begin(), wordsMap.end(), Compare("Evil"));
  cout &lt;&lt; count &lt;&lt; endl;
  }
  </code></pre>
  
  <p>I'm pretty sure it's just a case of my logic is wrong in the functions. I hope someone can help :)</p>