title: C++ reversing a string
body: <p>I'm trying to reverse a string in my C++ code line below <code>revStr.at(j) = str.at(size);</code></p>
  
  <p>But it doesn't change any of the elements in <code>revStr</code>.</p>
  
  <p>Is there another way to do it without using any libraries.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include&lt;sstream&gt;
  #include &lt;iterator&gt;
  using namespace std;
  
  
  int main() {
  
      ostringstream d;
  
      long long c = 123456789;
      d &lt;&lt; c;
      //cout &lt;&lt; c &lt;&lt; endl;
      string str = d.str();
      //cout &lt;&lt; str.at(0) &lt;&lt; endl;
      int size = str.size() - 1;
      //cout &lt;&lt; size &lt;&lt; endl;
      ostringstream e;
      e &lt;&lt; str;
      string revStr = e.str();
  
  for (int i = size; size==0; size--) {
      //cout &lt;&lt; str.at(size);
  
          int j = 0;
          revStr.at(j) = str.at(size);
          j++;
  
  } // End For
  
  cout &lt;&lt; "Original String is  :" &lt;&lt; str &lt;&lt; endl;
  cout &lt;&lt; "Reversed String is  :" &lt;&lt; revStr &lt;&lt; endl;
  
  }
  </code></pre>