title: How can I pass character pointer reference to function and get affected value back?
body: <p>In this code I passed a character pointer reference to function test
  and in function test I malloc size and write data to that address and after this I print it and got null value.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt; 
  
  void test(char*);
  
  int main()
  {
  
   char *c=NULL ;
  
  
   test(c);
   printf("After test string is %s\n",c);
   return 0;
  }
  
  
  
  void test(char *a)
  {
   a = (char*)malloc(sizeof(char) * 6);
   a = "test";
   printf("Inside test string is %s\n",a);
  }
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>Inside test string is test
  After test string is (null)
  </code></pre>