title: Why can't I overwrite an array (which passed to another function)with a dynamically allocated array?
body: <p>Here is the code I tried:</p>
  
  <pre><code>    void check(char*, int);
  int main(){
      int len;
      char* str="stack over flow";
      len=strlen(str);
      check(str,len);
      getch();
      return 0;
  }
  void check(char* str,int len)
  {
      char* arr;int i=0;
      arr=(char*)malloc(sizeof(char)*len);
      arr="over flow stack";
      while(arr[i]!='')
      {
          str[i]=arr[i];//here the error is thrown
          i++;
      }
      puts(str);
  }
  </code></pre>
  
  <p>when I tried to print back elements of arr into str I'm getting error.</p>