title: Write a recursive version of the function reverse(s), which reverses the string s in place.I cant seem to find the error
body: <p>This is a question from K and R. And when i try compiling it its says Segmentation fault (core dumped). I cant seem to find the error however.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  </code></pre>
  
  <p>This does your basic swap</p>
  
  <pre><code> void swap(char s[], int i, int j) {
      char temp;
      temp = s[i];
      s[i] = s[j];
      s[j] = temp;
  }
  
  
  void reverse(char s[]){
      int i, j;
  
      if (i == 0) 
          j = strlen(s)-1;
      swap(s, i, j);
      j--;
      i++;
      // Here is where the problem arises. When i don't call the function here the program works perfectly  (The limitation being only the first and last char get swapped) otherwise it gives an error saying segmentation fault
      if (i &lt; j)
          reverse(s);
  }
  
  int main () {
      int i;
      char s[10] = "hello";
      reverse(s);
      printf("%s", s);
  }
  </code></pre>