title: C++ Reversal string using pointers
body: <p>I have been given the task to receive a string input from the user and reverse the order of the string and print the result out. My code is this: </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstring&gt;
  #include &lt;string&gt;
  using namespace std;
  
  int main() {
      string input;
      char *head = new char, *tail = new char;
      char temp;
      //Get the string from the user that will be reversed
      cout &lt;&lt; "Enter in a string that you want reversed: ";
      getline(cin, input);
      //Create and copy the string into a character array
      char arr[input.length()];
      strcpy(arr, input.c_str());
      //Set the points of head/tail to the front/back of array, respectably
      head = &amp;arr[0]; tail = &amp;arr[input.length()-1];
      //Actual reversal part of the code (Does not work)
      for(int i=0; i&lt;input.length(); i++) {
          temp = *(tail);
          *tail = *head;
          *head = temp;
          tail --; head ++;
      }
      //Print the character array
      for(int i=0; i&lt;input.length(); i++) {
          cout &lt;&lt; arr[i];
      }
      //Free up memory
      delete head; delete tail;
      head = NULL; tail = NULL;
      return 0;
  }
  </code></pre>
  
  <p>When I print it, literally nothing has been changed and I can't seem to understand why as I'm brand new to pointers. This is the specific block that I'm having trouble with: </p>
  
  <pre><code>    for(int i=0; i&lt;input.length(); i++) {
          temp = *(tail);
          *tail = *head;
          *head = temp;
          tail --; head ++;
      }
  </code></pre>
  
  <p>Any input on how to fix this or pointer knowledge in general that'd help is greatly appreciated.</p>