View Single Post
Old 2012-05-30, 20:05   #10
Basketry That Evening!
Dubslow's Avatar
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88

3×29×83 Posts

Originally Posted by chalsall View Post
strncpy(dest, src, length);
dest[length-1]=0; pretty safe....
But you don't know for sure without further code if some part of src got clobbered. strcpy_s throws an error if dest is too small for src.
Originally Posted by MSFT
If strDestination or strSource is a null pointer, or if the destination string is too small, the invalid parameter handler is invoked as described in Parameter Validation. If execution is allowed to continue, these functions return EINVAL and set errno to EINVAL.

Upon successful execution, the destination string will always be null terminated.

Last fiddled with by Dubslow on 2012-05-30 at 20:06 Reason: It seems MSFT deserves credit for something they appear to have done better than on linux
Dubslow is offline   Reply With Quote