title: String Literals
body: <p>I have few doubts about string literals in c++.</p>
  
  <pre><code>char *strPtr ="Hello" ;
  char strArray[] ="Hello";
  </code></pre>
  
  <p>Now strPtr and strArray are considered to be string literals.</p>
  
  <p>As per my understanding string literals are stored in read only memory so we cannot modify their values.</p>
  
  <p>We cannot do</p>
  
  <pre><code>strPtr[2] ='a';
  and strArray[2]='a';
  </code></pre>
  
  <p>Both the above statements should be illegal.
  compiler should throw errors in both cases.</p>
  
  <p>Compiler keeps string literals in read only memory , so if we try to modify them compiler throws errors.</p>
  
  <p>Also const data is also considered as readonly.</p>
  
  <p>Is it that both string literals and const data are treated same way ?
  Can I remove constantness using const_cast from string literal can change its value?</p>
  
  <p>Where exactly do string literals are stored ? (in data section of program)</p>