title: How to store a string into a char pointer?
body: <p>I have a confusion with the following program</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  void main()
  {
  char *string;
  string = (char *)malloc(5);
  string = "abc";  // &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; why *string="abc" is not working. How string = "abc" is working?
  printf("%s", string);
  }
  </code></pre>
  
  <p>But the same program with integer is working</p>
  
  <pre><code>char *i;
   i=(int *)malloc(sizeof(int));
  *i=4;  &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; this is working fine
  printf("%d",*i);
  </code></pre>