title: What is effective in this case, assigning address of pointer to pointer or using strcpy?
body: <p>I want to know the efficient way of assigning the string or copying the string using the pointer.</p>
  
  <p>Using <code>strcpy()</code> is better than just assigning pointer to the pointer?</p>
  
  <pre><code>void local_var() {
      // method 1
      char *a = "simple test";
      char *b;
      b = a;
      printf("a:%s\n", b);    
  
      fflush(stdout);
      //method 2
      char *c = "test test";
      char *d;
      d=malloc(sizeof(char) * strlen(c));
      strcpy(d,c); 
      printf("a:%s\n", d);
      free(d);  //EDIT: I missed to add in typing the question.
  }
  </code></pre>