title: Segmentation fault when detabing string
body: <p>I have a function to replace tabs with spaces in a string that looks like this:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  char *detab(char *string) 
  {
      for (int i = 0; string[i] != '\0'; i++)
          if (string[i] == '\t')
              string[i] = ' ';
      return string;
  }
  
  int main(int argc, char **argv)
  {
      char *string = "\thello\thello";
      detab(string);
      printf("%s\n", string);
      return 0;
  }
  </code></pre>
  
  <p>But when I run it on <code>"\thello\thello\t"</code>, it produces a segmentation fault. Why does it do this? I'm pretty new to C, so I may be missing something trivial.</p>