title: Function to reverse string in C
body: <p>I wrote this function to reverse a string in C, but when switching characters in the string the program crashes. I have no idea what's causing it, so any help would be appreciated.</p>
  
  <pre><code>void reverse(char s[])
  {
      char c;
      int i;
      int j;
  
      for (i = 0, j = (strlen(s) - 1); i &lt; j; i++, j--)
      {
          c = s[i];
          s[i] = s[j]; //An error occurs here
          s[j] = c;
      }
  
      printf("%s", s);
  }
  
  main()
  {
      reverse("Example");
  }
  </code></pre>