title: What is the reason for segmentation fault in void reverse(char*)?
body: <p>When I run this code, I am getting segmentation fault.
  How can I fix it?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void reverse(char *str)
  {
      char *end=str;
      char temp;
      while(*end)
      {
      ++end;
      }
      --end;
  
      while(str &lt; end)
      {
          temp=*str;
          *str=*end;
          *end=temp;
          str++;
          end--;
      }
  }
  
  void main()
  {
      char *s="random";
      reverse(s);
  }
  </code></pre>