title: Reverse strings stored in array of pointers
body: <blockquote>
    <p>Write a program to reverse the strings stored in the following array of pointers to strings:</p>
  </blockquote>
  
  <pre><code>char *s[ ] = {
    "To err is human...",
    "But to really mess things up...",
    "One needs to know C!!"
  };
  </code></pre>
  
  <blockquote>
    <p>Hint: write a function <code>xstrrev ( string )</code> which should reverse
    the contents of one string. Call this function for reversing each
    string stored in <code>s</code>.</p>
  </blockquote>
  
  <p>Why am I not getting correct output with this code?</p>
  
  <pre><code>#include "stdafx.h"
  #include "conio.h"
  #include "stdio.h"
  #include "string.h"
  
  using namespace System;
  
  void xstrrev (char str[])
  {
      int i,l;
      char temp;
      l=strlen(str);
  
      for (i=0;i&lt;(l/2);++i)
      {
          temp=*(str+i);
          *(str+i)=*(str+i+l-1);
          *(str+i+l-1)=temp;
      }
  }
  
  void main ()
  {
  char *s[] = {
          "To err is human...",
          "But to really mess things up...",
          "One needs to know C!!"
      };
      xstrrev(s[0]);
      xstrrev(s[1]);
      xstrrev(s[2]);
      puts(s[0]);
      puts(s[1]);
      puts(s[2]);
      getch();
  }
  </code></pre>