title: How to copy a std::string to unsigned char array?
body: <p>How to copy a std::string (sample) to unsigned char array (trap)?</p>
  
  <pre><code>int main() {
      unsigned char trap[256];
      std::string sample = ".1.3.6.1.4";
      strcpy(trap,sample.c_str());
      std::cout &lt;&lt; trap &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p><strong>Above code throws error:</strong></p>
  
  <pre><code>time.cpp: In function ‘int main()’:
  time.cpp:20: error: invalid conversion from ‘unsigned char*’ to ‘char*’
  time.cpp:20: error:   initializing argument 1 of ‘char* strcpy(char*, const char*)’
  </code></pre>