title: C++ Reverse the order of words in a string with pointers
body: <p>This is my attempt at taking an input and then produce an output with the words in the reverse order. Note: I can only use pointers.</p>
  
  <pre><code>    Input: What is your name? 
      Output: name? your is What
  </code></pre>
  
  <p>I have looked at the other solutions posted here and thought tried to implement them as much as possible but I keep running into problems. Currently it only displays the first letter of the line. I would appreciate any help to fix it!</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  #include &lt;cstring&gt;
  
  int main( )
  {
      char input[255] = {' '};
      char *head, *tail;
      char temp; 
      int i = 0; 
  
      cin &gt;&gt; input;
  
      head = input;
      tail = input;
  
      while(*tail!='\0')
      {
          tail++;
      }
  
      while (tail &lt;= head){
          temp = *head;
          *head=*tail;
          *tail=temp;
  
          *head++;
          *tail--;
      }
  
      cout &lt;&lt; input;
      cout &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>