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