title: C++ How to capitalize first word of each sentence/line in a string?
body: <p>I am loosing my hair right now. I have a string, which i manipulate to start a new line/sentence after a punctuation, but I cant understand how I can capitalize the first word of each sentence? Except for this, i can not get out of the loop to change the dot into a dot and new line.</p>
  
  <pre><code>int main()
  {
      string const txt1 = "Candy is good for your health.";
      string const text2 = "All kids should buy candy.";
      string const text3 = "Candy nowadays is a hit among kids.";
      string const text4 = "Every meal should include candy.";
  
  
      string text = text1 + text2 + text3 + text4;
  
      transform(text.begin(), text.end(), text.begin(), ::tolower);
  
      while (text.find("candy") != string::npos)
          text.replace(text.find("candy"), 3, "fruit");
      string_replace_all(text, ".", ".\n");
  </code></pre>
  
  <p>This is what i have added so far:</p>
  
  <pre><code>string line, total = ""; istringstream stream(text);
  while (getline(stream, line, '\n'))
  {
      if (line.size() &gt; 0)
          total += (char)toupper(line[0]) + line.substr(1) + "\n";
      else total += "\n";
  }
  </code></pre>