title: Why is there a question mark at the end of the string?
body: <p>Please help me to figure out why there is a question mark at my string output. I have been working on this simple reverse a string practice. My code can do it correctly. Then I try to store the reversed string into an array and then convert this array to a string. So here is something wired happened. There is always a question mark at the end of that string. Please teach me the reason of it, and how to get rid of this question mark. Here is my code. Thank you so much</p>
  
  <pre><code>#include &lt;string&gt;
  using namespace std;
  
  int main()
  {
      cout&lt;&lt;"Please enter a string."&lt;&lt;endl;
      string str;
      cin &gt;&gt; str;
      int i=0;
      int length = str.length();
      char arr[length];
      //cout&lt;&lt;length;
      while (length != 0) {
          arr[i] = str.at(length-1);
          length--;
          cout&lt;&lt;arr[i];
          ++i;
      }
      cout&lt;&lt;endl;
      string stri(arr);
      cout&lt;&lt;endl&lt;&lt;stri&lt;&lt;endl;
      cout&lt;&lt;stri[4];
      return 0;
  }
  </code></pre>