title: Anagram solver in C++
body: <p>I am working on a project for school and I am stuck on what I believe is just a small part but I cant figure it out. </p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;locale&gt;
  #include &lt;vector&gt;
  #include &lt;algorithm&gt;
  #include &lt;set&gt;
  
  using namespace std;
  
  int main(int argc, char* argv[])
  {
      set&lt;string&gt; setwords;
      ifstream infile;
      infile.open("words.txt"); //reads file "words.txt"
      string word = argv[1]; // input from command line
      transform(word.begin(), word.end(), word.begin(), tolower); // transforms word to lower case.
      sort(word.begin(), word.end()); // sorts the word
      vector&lt;string&gt; str; // vector to hold all variations of the word
  
      do {
          str.push_back(word);
      }
      while (next_permutation(word.begin(), word.end())); // pushes all permutations of "word" to vector str         
  
      if (!infile.eof())
      {
          string items;
          infile &gt;&gt; items;
          setwords.insert(items); //stores set of words from file
      }
  
      system("PAUSE");
      return 0;
  }
  </code></pre>
  
  <p>Now I need to compare the words from the file and the permutations stored in vector <code>str</code>
  and print out the ones that are real words. </p>
  
  <p>I know I need to use the find method of the set class. I am just not sure how to go about that. I was trying something like this with no luck, but my thought process is probably wrong.</p>
  
  <pre><code>for (unsigned int i = 0; i &lt; str.size(); i++)
      if (setwords.find(word) == str[i])
          cout &lt;&lt; str[i] &lt;&lt; endl;
  </code></pre>
  
  <p>If you guys could help or point me in the right direction I would greatly appreciate it.</p>