title: Copy const char*
body: <p>I'm receiving a c-string as a parameter from a function, but the argument I receive is going to be destroyed later. So I want to make a copy of it.</p>
  
  <p>Here's what I mean:</p>
  
  <pre><code>class MyClass
  {
  private:
   const char *filename;
  
  public:
   void func (const char *_filename);
  }
  
  void MyClass::func (const char *_filename)
  {
   filename = _filename; //This isn't going to work
  }
  </code></pre>
  
  <p>What I want to achieve is not simply assign one memory address to another but to copy contents. I want to have filename as "const char*" and not as "char*".</p>
  
  <p>I tried to use strcpy but it requires the destination string to be non-const.</p>
  
  <p>Is there a way around? Something without using const_cast on filename?</p>
  
  <p>Thanks.</p>