Problem with paragraphs

Hi, people of the internet.

I've got a problem. I figured out this piece of code to "concatenate" paragraphs.

1
2
3
4
5
6
7
8
9
10
11
12
  void makeParagraph()
  {
    string str;
    string paragraph;
    do
    {
        getline(cin, str);
        paragraph += str + "\n";
    }while(str.length() > 0);

    cout << paragraph << endl;
  }


The issue comes when I paste some text. My do/while breaks, the text is shown and the program finishes (I'm kinda lazy).

How can I fix it?
You're copying and pasting something with an empty line, which getline won't take in, and str.length() will equal 0.
Topic archived. No new replies allowed.