title: How to align a paragraph to the right in c++?
body: <p>For example this text will become:</p>
  
  <pre><code>lui Andino ii place
  mult informatica si doreste
  sa mearga la olimpiada
  pentru a-si dovedi calitatile de mare informatician
  </code></pre>
  
  <pre><code>                                lui Andino ii place
                          mult informatica si doreste
                               sa mearga la olimpiada
  pentru a-si dovedi calitatile de mare informatician
  </code></pre>
  
  <p>My idea is to find the longest size of a text line(named maxx in my code) and add to the other lines "maxx - size of the text line" spaces.</p>
  
  <p>for example:</p>
  
  <pre><code>I eat.
  I eat everyday at 5 pm in the morning.
  </code></pre>
  
  <p>I will place in the front "the size of second line of text minus the first line of text" spaces.</p>
  
  <p>This is what I ve done until now.</p>
  
  <pre><code>        cin &gt;&gt; t ///t is the number of line of text
          int maxx = 0, t1 = t, k = 0;
          vector&lt;string&gt; str;
          while(t--)
          {
              string s;
              getline(cin, s);
              str.push_back(s);
  
  
              if (s.size() &gt; maxx)
                  maxx = s.size();
          }
          for (int j = 0 ; j &lt; t1; j++)
          {
              if (str[i].length() &lt; maxx)
              {
                  str[i].insert(0, ' ', maxx - str[i].length());
              }
              cout &lt;&lt; str[i] &lt;&lt; "\n";
          }
  </code></pre>
  
  <p>It works all fine, unless some lines of my output are filled with unknown caracter.</p>
  
  <p>This is what the program compiles:</p>
  
  <pre><code>                                                lui Andino ii place
  mult informatica si doreste
  sa mearga la olimpiada
  pentru a-si dovedi calitatile de mare informatician
  </code></pre>
  
  <p>Thanks for helping me!</p>