title: How does strcpy_s work?
body: <p>As we all know, strcpy_s is a safety version of strcpy. </p>
  
  <p>But I wonder how it works ...</p>
  
  <p>let's see some examples.</p>
  
  <p>strpy_s's declaration：<br>
  <strong>errno_t strcpy_s(_CHAR *_DEST, size_t _SIZE, const _CHAR *_SRC)</strong></p>
  
  <p>eg1</p>
  
  <pre><code>char dest[5];
  char* src = "abcdefg";
  strcpy_s(dest,5,src);
  </code></pre>
  
  <p>It will return an assertion.<br>
  I think I can understand this, use <strong>_SIZE</strong> to make sure we can't copy more characters than <strong>_SIZE</strong></p>
  
  <p>But.. I can't understand this:</p>
  
  <pre><code>char dest[5];
  char* src = "abcdefg";
  strcpy_s(dest,10,src);
  </code></pre>
  
  <p>we can still get a assertion, how did that happened?</p>
  
  <p>ps,error was:</p>
  
  <blockquote>
    <p>Debug Assertion Failed<br> expression : (L"Buffer is too small "&amp;&amp;0)</p>
  </blockquote>
  
  <p><br>
  In VS2013</p>
  
  <p><strong>will strcpy_s checks the size of dest inside its body?? and if it's true , how? how to check a pointer like _DEST?</strong></p>