Extending a program to count line frequency
<p>I have this simple program to count the word frequency:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;map&gt;
#include &lt;cctype&gt;
#include &lt;string&gt;
using namespace std;
int main(void) {
  map&lt;string, int&gt; words;
  map&lt;string, int&gt;::iterator i;
string s;
while (cin &gt;&gt; s) {
    transform(s.begin(), s.end(), s.begin(), ::tolower);
words[s]++;
  }
for (i=words.begin(); i != words.end(); i++)
    cout &lt;&lt; i-&gt;first &lt;&lt; " " &lt;&lt; i-&gt;second &lt;&lt; endl;
return 0;
</code></pre>

<p>Now how do I make it to count line frequency instead of word frequency. Each line is separated by '\n' new line character in the input.</p>
