title: Counting occurrences in a vector
body: <p>This program reads strings of numbers from a txt file, converts them to integers, stores them in a vector, and then tries to output them in an organized fashion like so....</p>
  
  <p>If txt file says:</p>
  
  <pre><code>7 5 5 7 3 117 5
  </code></pre>
  
  <p>The program outputs:</p>
  
  <pre><code>3
  5   3
  7   2
  117
  </code></pre>
  
  <p>so if the number occurs more than once it outputs how many times that happens. Here is the code so far.</p>
  
  <pre><code>#include "std_lib_facilities.h"
  
  int str_to_int(string&amp; s)
  {
      stringstream ss(s);
      int num;
      ss &gt;&gt; num;
      return num;
  }
  
  int main()
  {
      cout &lt;&lt; "Enter file name.\n";
      string file;
      cin &gt;&gt; file;
      ifstream f(file.c_str(), ios::in);
  
      string num;
      vector&lt;int&gt; numbers;
      while(f&gt;&gt;num)
      {
          int number = str_to_int(num);
          numbers.push_back(number);
      }
  
      sort(numbers.begin(), numbers.end());
  
      for(int i = 0; i &lt; numbers.size(); ++i)
      {
       if(i = 0 &amp;&amp; numbers[i]!= numbers[i+1]) cout &lt;&lt; numbers[i] &lt;&lt; endl;
       if(i!=0 &amp;&amp; numbers[i]!= numbers[i-1])
       {
            cout &lt;&lt; numbers[i] &lt;&lt; '\t' &lt;&lt; counter &lt;&lt; endl;
            counter = 0;
       }
       else ++counter;
      }
   }
  </code></pre>
  
  <p>Edit: Program is getting stuck. Looking for an infinite loop right now.</p>