title: How to reverse a multidimensional array in C?
body: <p>I need to reverse a 2d array that was made with pointer notation.</p>
  
  <p>To be clear, if the array is</p>
  
  <pre><code>A B C D E
  F G H I J
  K L M N O
  </code></pre>
  
  <p>I need:</p>
  
  <pre><code>E D C B A
  J I H G F
  O N M L K
  </code></pre>
  
  <p>My code so far:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #define HEIGHT 3
  #define WIDHT 7
  
  void print (char *imprimir)
  {
      int i,j;
      for (i=0;i&lt;HEIGHT;i++)
      {
          for (j=0;j&lt;WIDHT;j++)
          {
              printf ("%2c",*(imprimir+(i*WIDHT)+j));
          }
          printf ("\n");
      }
  }
  
  int main()
  {
      //FILLING THE ARRAY
      char *array=malloc(WIDHT*HEIGHT);
      int i,j;
      for (i=0;i&lt;HEIGHT;i++)
      {
          for (j=0;j&lt;WIDHT;j++)
          {
              *(array+(i*WIDHT)+j)=(i*WIDHT)+j+'a';
          }
      }
      print (array);  
      //TRYING TO REVERSE IT
      char *tmp=malloc(WIDHT);
      for (i=0;i&lt;HEIGHT;i++)
      {
          for (j=0;j&lt;WIDHT/2;j++);
          {
              *tmp=*(array+(i*WIDHT)+j);
              *(array+(i*WIDHT)+j)=*(array+(i*WIDHT)+(WIDHT-j));
              *(array+(i*WIDHT)+(WIDHT-j))=*tmp;
          }
      }
      printf ("PRINTING RESULT!\n");
      print (array);  
  }
  </code></pre>