title: Reverse C-style String? - C++
body: <p>I want to use pointers to reverse a char array in C++.  I was wondering if there is anything that I should do differently? Am I doing this correctly? Is there a more efficient way to accomplish this? </p>
  
  <p>My small program:</p>
  
  <pre><code>int main ( )
  {
      char buffer[80];
  
      PrintHeader();
  
      cout &lt;&lt; "\nString reversal program";
      cout &lt;&lt; "\nType in a short string of words.";
      cout &lt;&lt; "\nI will reverse them.";
      cout &lt;&lt; "\n:";
      cin.getline(buffer, 79);
  
      cout &lt;&lt; "\nYou typed " &lt;&lt; buffer;
      reverse (buffer);
      cout &lt;&lt; "\nReversed: " &lt;&lt; buffer;
  
      cout &lt;&lt; endl;
      system("PAUSE");
      return 0;
  
  }
  
  
  void reverse(char* string)
  {
      char* pStart, *pEnd;
      int length;
      char temp;
  
      length = strlen(string);
  
      pStart = string;
      pEnd = &amp;string[length - 1];
  
      while(pStart &lt; pEnd)
      {
          temp = *pStart;
          *pStart = *pEnd;
          *pEnd = temp;
          pStart++;
          pEnd--;
      }
  }
  </code></pre>