title: c++ const char* to char*
body: <p>I have the following function which initially performs some validation on function parameters.</p>
  
  <pre><code>char *doSomething(const char* first, const char* second) {
  
      if((first == nullptr || *first == '\0') &amp;&amp; (second == nullptr || *second == '\0')) {
          return nullptr;
      } else if (first == nullptr || *first == '\0') {
          return (char *) second;
      } else if (second == nullptr || *second == '\0') {
          return (char *) first;
      }
      //doSomething
  }
  </code></pre>
  
  <p>Does casting the function parameter return a new <code>char*</code> that points to a different area in memory? I don't want to allow someone using this function to manipulate the value that the constant parameters are pointing to. I would like a new <code>char*</code> to be returned with the same value as one of the parameters if one is <code>nullptr</code> or empty.</p>
  
  <p>Follow-up: Would a boolean variable be better here? I realize I'm performing the same check for each variable twice, but I wouldn't be utilizing this boolean anywhere else in this function's code.</p>