title: C++ Converting const char* to char*
body: <p>I want to create a new class that takes a string, and converts it to a character array,then saves it to its private variable. So, I am trying to convert <code>const char*</code> to <code>char*</code> because I want to be able to modify its content.</p>
  
  <pre><code>class MyClass {
  public:
      MyClass (const char* input) {
          // convert input to char* and assign it to carray
      }
  private:
      char carray[];
  };
  
  int main() {
      MyClass mc = "StackOverflow";
  }
  </code></pre>
  
  <p>I modified how the constructor takes the argument in various ways (<code>string&amp; input</code>,<code>input.c_str()</code>, etc.), but all of them failed with one of the errors below.</p>
  
  <pre><code>error: conversion from ‘const char [14]’ to non-scalar type ‘MyClass’ requested
  
  error: request for member ‘c_str’ in ‘s’, which is of non-class type ‘const char*’
  
  error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
  
  error: incompatible types in assignment of ‘const char*’ to ‘char [0]’
  </code></pre>
  
  <p>I looked at several examples on SO, but I still could not figure out. How can I do this?</p>