title: length() of string is returning 0 for a C++ program
body: <p>In the following code the length of the reversed string is being returned as zero which should not be the case:</p>
  
  <pre><code>int main() {
  
  string for_reversal;
  string reversed;
  int i,j,length, r_length;
  
  cout &lt;&lt; "Enter the string : \n";
  cin &gt;&gt; for_reversal;
  cout &lt;&lt; "Entered string is :  " &lt;&lt; for_reversal &lt;&lt;"\n";
  cout &lt;&lt; "String length is :  " &lt;&lt; for_reversal.length() &lt;&lt; "\n";
  length = for_reversal.length();
  
  for (i=0; i&lt;=length; i++)
  {
      reversed[i] = for_reversal[length - i-1];
      cout &lt;&lt; for_reversal[length-i] &lt;&lt; "\t";
  
  }
  
  
  reversed[length+1]='\0';
  cout &lt;&lt; "\n";
  
  r_length = reversed.length();
  cout &lt;&lt; "Reversed String length is : " &lt;&lt; r_length &lt;&lt; "\n";
  cout &lt;&lt; "Reversed String is : " &lt;&lt; reversed;
  
  return 0;
  }
  </code></pre>
  
  <p>Not sure whats going wrong here.</p>