title: Trying to copy strings without last characters using memcpy
body: <p>Newbie quetion here.</p>
  <p>So i have a const char* and need to copy it to a char* without the last two character.
  I already tried to use strncpy but i'm using c++ in vs and says it is deprectated.
  I cannot use std::string.
  Using memcpy prints me trash. I want to print <strong>adress</strong> but it prints me <strong>adress²²²²Üw</strong></p>
  <p>I will put my code here:</p>
  <pre><code>#include &lt;cstring&gt;
  #include &lt;iostream&gt;
  #include &lt;stdio.h&gt;
  
  
  int main()
  {
      const char* ident = &quot;adress.P&quot;;
      char* tm_name;
  
      if( (tm_name = (char*)malloc(sizeof(char) * (strlen(ident) - 2))) != NULL)
      memcpy( tm_name, ident, strlen(ident) - 2);
  
      printf(&quot;tm_name = %s&quot;, tm_name);
      return 0;
  }
  </code></pre>
  <p>best regards,
  Guilherme Gil</p>