The problems of const data in c++ : <pre><code>const int *a = new int(100);
int *ptr = (int*) a;
cout &lt;&lt; *a &lt;&lt; endl;
*ptr = 1000;
cout &lt;&lt; *a &lt;&lt; endl;

const int b = 100;
int *c = (int*)&amp;b;
*c = 200;
cout &lt;&lt; &amp;b &lt;&lt; " " &lt;&lt; b &lt;&lt; endl;
cout &lt;&lt; c &lt;&lt; " " &lt;&lt; *c &lt;&lt; endl;
</code></pre>

<p><a href="https://i.stack.imgur.com/OI4IA.png" rel="nofollow noreferrer">print out</a></p>

<ol>
<li>While I use *ptr, I can change the const data *a. Why?</li>
<li>Both the address of b and *c are the same, but the data are different. Why?</li>
</ol>
