title: How to detect a newline in string input in C++
body: <p>I want to count each newline <br>
  If the input like this:<br></p>
  
  <blockquote>
    <p>Hi moon <br>this day I wanna  <br>help</p>
  </blockquote>
  
  <p>Should be the output like this:</p>
  
  <blockquote>
    <p>1 Hi moon<br> 2 this day I wanna <br> 3 help
    <br></p>
  </blockquote>
  
  <p>I write this code:</p>
  
  <pre><code>int main() {
      string str; int c = 0;
      cin &gt;&gt; str;
      int j = 0;
      string t[200];
      while (str != ";")
      {
          t[j] = str;
          cin &gt;&gt; str;
  
      }
      for (int i = 0; i &lt; j;i++){
      cout &lt;&lt; c &lt;&lt; " " &lt;&lt; t[j];
  
      if (t[j] == "\n") c++;
  }
  
      system("Pause");
      return 0;
  }
  </code></pre>
  
  <p><br>
  and I was to try :</p>
  
  <pre><code>int c[100];
      cin &gt;&gt; str;
      int j = 0;
      string t[200];
      while (str != ";")
      {
          string temp;
          t[j] = str;
          temp = t[j];
          if (temp.find("\n"))
              c[j] += 1;
          cin &gt;&gt; str;
  
      }
      for (int i = 0; i &lt; j;i++){
      cout &lt;&lt; c[i] &lt;&lt; " " &lt;&lt; t[j];
  
  }
  </code></pre>
  
  <p>Can anyone tell to me how to detect a newline in string input and print it? </p>