title: Difference between char *str="STRING" and char str[] = "STRING"?
body: <p>While coding a simple function to remove a particular character from a string, I fell on this strange issue:</p>
  
  <pre><code>void str_remove_chars( char *str, char to_remove)
  {
      if(str &amp;&amp; to_remove)
      {
         char *ptr = str;
         char *cur = str;
         while(*ptr != '\0')
         {
             if(*ptr != to_remove)
             {
                 if(ptr != cur)
                 {
                     cur[0] = ptr[0];
                 }
                 cur++;
             }
             ptr++;
         }
         cur[0] = '\0';
      }
  }
  int main()
  {
      setbuf(stdout, NULL);
      {
          char test[] = "string test"; // stack allocation?
          printf("Test: %s\n", test);
          str_remove_chars(test, ' '); // works
          printf("After: %s\n",test);
      }
      {
          char *test = "string test";  // non-writable?
          printf("Test: %s\n", test);
          str_remove_chars(test, ' '); // crash!!
          printf("After: %s\n",test);
      }
  
      return 0;
  }
  </code></pre>
  
  <p>What I don't get is why the second test fails?
  To me it looks like the first notation <code>char *ptr = "string";</code> is equivalent to this one: <code>char ptr[] = "string";</code>.</p>
  
  <p>Isn't it the case?</p>