title: Passing char pointer as argument to function
body: <p>This porgram prints different permutations of a string.It works correctly if I declare string as char array in main and pass array name in printAnagram function.But if I declare string as
  char* s = "hello" and pass 's' then it crashes. Why?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;conio.h&gt;
  
  void printAnagram(char *str, int b, int e);
  
  int main()
  {
      char *s = "ABC"; // works fine when char s[] = "ABC" is used.
      printAnagram(s, 0, 2);
      return 0;
  }
  
  void swap(char *a, char* b)
  {
      char temp = *a;
      *a = *b;
      *b = temp;
  }
  void printAnagram(char *str, int b, int e)
  {
      int i = 0;
      if(b==e)
          printf("%s\n", str);
      else
      {
          for(i=b;i&lt;=e;i++)
          {
              swap((str+b),(str+i));
              printAnagram(str, b+1, e);
              swap((str+b), (str+i));
          }
      }
  }
  </code></pre>