title: Creating a dictionary from a text file
body: <p>This code is supposed to output each word in the file along with the number of times it appears, (EDIT: IGNORING UPPERCASE/LOWERCASE differences). Currently, it is not doing this correctly. Is this due to spaces/punctuation of some kind?       </p>
  
  <pre><code>struct entry
      {
          string word;
          int count;
  
      };  
  
  
        int main()
          {
              ifstream input1;
              input1.open("Base_text.txt");
  
              if (input1.fail())
              {
                  cout&lt;&lt;"Input file 1 opening failed."&lt;&lt;endl;
                  exit(1);
              }
  
              ifstream input2;
              input2.open("Test_file.txt");
  
              if (input2.fail())
              {
                  cout&lt;&lt;"Input file 2 opening failed."&lt;&lt;endl;
                  exit(1);
              }
  
              vector&lt;entry&gt; base;
  
              make_dictionary(input1, base);
  
              int i;
              for (i=0; i&lt;base.size(); i++)
              {
                  cout&lt;&lt;base[i].word&lt;&lt;": "&lt;&lt;base[i].count&lt;&lt;endl;
              }
  
  
          }
  
          void make_dictionary(istream&amp; file, vector&lt;entry&gt;&amp; dict)
          {
  
  
              string word;
  
              while (file&gt;&gt;word)
              {
                  int i;
                  bool found = false;
  
                  for (i=0; i&lt;dict.size(); i++)
                  {
                     if (dict[i].word==word)
                     {
                         dict[i].count++;
                         found=true;
  
                     }
                  }
  
  
                  if(!found)
                  {
                      entry ent;
                      ent.word = word;
                      ent.count = 1;
                      dict.push_back(ent);
                  }
              }
  
  
          }
  </code></pre>
  
  <p>Input</p>
  
  <pre><code>This is some simple base text to use for comparison with other files.
  You may use your own if you so choose; your program shouldn't actually care.
  For getting interesting results, longer passages of text may be useful.
  In theory, a full novel might work, although it will likely be somewhat slow.
  </code></pre>
  
  <p>Current (incorrect) output:</p>
  
  <pre><code>This: 1
  is: 1
  some: 1
  simple: 1
  base: 1
  text: 2
  to: 1
  use: 2
  for: 1
  comparison: 1
  with: 1
  other: 1
  files.: 1
  You: 1
  may: 2
  your: 2
  own: 1
  if: 1
  you: 1
  so: 1
  choose;: 1
  program: 1
  shouldn't: 1
  actually: 1
  care.: 1
  For: 1
  getting: 1
  interesting: 1
  results,: 1
  longer: 1
  passages: 1
  of: 1
  be: 2
  useful.: 1
  In: 1
  theory,: 1
  a: 1
  full: 1
  novel: 1
  might: 1
  work,: 1
  although: 1
  it: 1
  will: 1
  likely: 1
  somewhat: 1
  slow.: 1
  </code></pre>
  
  <p>We are not allowed to use maps on this project. Any ideas on where I've gone wrong?</p>