Should I use const_cast?
<p>So I'm doing some parsing of C-strings in a function that looks like this:</p>

<pre><code>void parse(const char** params, int numParams);
</code></pre>

<p>I wanted to pull some information out of one of the strings stored in params, so I wrote code that looked like this:</p>

<pre><code>char* charPointer;
charPointer = params[0];
</code></pre>

<p>The compiler didn't like this and told me that it can't convert from a const char* to a char*. I understand the reasoning behind this (in theory I could write to the address pointed to by charPointer but not by params[0] if it let me) but what I don't understand is how I should be getting around it. I know of two ways to fix this error but I don't know which one is "proper" or really what the differences are between them. The first is:</p>

<pre><code>const char* charPointer;
charPointer = params[0];
</code></pre>

<p>And the second method is:</p>

<pre><code>char* charPointer;
charPointer = const_cast&lt;char*&gt;(params[0]);
</code></pre>

<p>So which is better and why?</p>