title: need help with C++ using maps to keep track of words in a INPUT file
body: <p>Let say i have a text file with</p>
  
  <pre><code>today is today but
  tomorrow is today tomorrow
  </code></pre>
  
  <p>then using maps how can i keep track of the words that are repeated? and on which line it repeats?
  so far i have each string in the file read in as a temp and it is stored in the following way:</p>
  
  <pre><code>    map&lt;string,int&gt; storage;
  
      int count = 1 // for the first line of the file
  
      if(infile.is_open()){
       while( !infile.eof() ){ 
        getline(in, line);
        istringstream my_string(line);
        while(my_string.good()){
           string temp;
           my_string &gt;&gt; temp;
  
      storage[temp] = count
      }
      count++;// so that every string read in the next line will be recorded as that line.
  }
  }
     map&lt;string,int&gt;::iterator m;
     for(int m = storage.begin(); m!= storage.end(); m++){
        out&lt;&lt;m-&gt;first&lt;&lt;": "&lt;&lt;"line "&lt;&lt;m-&gt;second&lt;&lt;endl;
  }
  </code></pre>
  
  <p>right now the output is just</p>
  
  <pre><code>but: line 1
  is: line 2
  today: line 2
  tomorrow: line 2
  </code></pre>
  
  <p>But instead..
  it should print out(no repeating strings):</p>
  
  <pre><code>today : line 1 occurred 2 times, line 2 occurred 1 time.
  is: line 1 occurred 1 time, line 2 occurred 1 time.
  but: line 1 occurred 1 time.
  tomorrow: line 2 occurred 2 times.
  </code></pre>
  
  <p>Note: the order of the string does not matter.</p>
  
  <p>Any help would be appreciated. Thanks.</p>