title: Reverse array content using recursion (C Language)
body: <p>Function reverseAr() takes in two arguments, an array of char (ar[]) and the size of the array (n), and then reverses the content of the array (without the use of another array). The function will then return the result to the calling function through parameter ar.</p>
  
  <p>My code can't seem to run, I think I'm passing the values in between the functions wrongly, but I can't figure out where.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>#define _CRT_SECURE_NO_WARNINGS
  #include &lt;stdio.h&gt; 
  #include &lt;string.h&gt; 
  #include &lt;math.h&gt; 
  
  void reverseAr(char ar[], int n);
  
  int main()
  {
      char str[128];
      int len;
  
      printf("\nEnter an array of characters: ");
      gets(str);
      len = strlen(str);
      printf("The reversed array of characters is = %s\n", reverseAr(str, len));
  
      return 0;
  }
  
  void reverseAr(char ar[], int n)
  {
      char temp = ar[0];
      ar[0] = ar[n - 1];
      ar[n - 1] = temp;
      if (n &gt; 1) 
      {
          reverseAr(++ar, n - 2);
      }
  }
  </code></pre>
  
  <p>Expected output:</p>
  
  <pre><code>Enter an array of characters: abcde
  The reversed array of characters is = edcba
  </code></pre>