title: dynamically allocated char
body: <pre><code>int main()
  
  {
     char *second= new char("hello");
     char *first="hi";
     char third[]="new";
  }
  </code></pre>
  
  <p>I am new to c++ and don't really understand how char works, why the first one give a compiler error, and what are the differences of those 3 way of declaration , the strength and benefits of declaring it in a particular way.</p>
  
  <p>Thanks </p>
  
  <p>Hmm, as someone mentions that the second form is read only, why could I Change it. suppose I have the code below</p>
  
  <pre><code> int main()
  
  {
     char *second= new char("hello");
     char *first="hi";
     char third[]="new";
     first="world";
  }
  </code></pre>
  
  <p>code like above will still execute, why is it so? , then which form is better if I want to read an input but don't know the size of the string? </p>