4 ms·
The only difference between strcpy_s and strlcpy, other than taking arguments in a different order and being more annoying to type, is that if an overflow would
by comex 14y ago
The only difference between strcpy_s and strlcpy, other than taking arguments in a different order and being more annoying to type, is that if an overflow would occur, it sets destination[0] to 0 rather than truncating. This is probably an improvement, since truncation can cause security problems if you're building filenames and such (though, should you fail the test accidentally, I suspect it's much harder to track down why a string somewhere in your app became empty than why it was truncated)... but is it really worth switching to yet another string copy function?
(well, from a BSD perspective. Apparently strcpy_s has been around on Windows since Windows 95.)
- yuhong 14y agoNope, it is a CRT function introduced in VC8.
- comex 14y agoedit: never mind, I get it. it's compatible with programs targeting Windows 95, since it's a crt function, but not Windows 95 headers. I was confused by http://msdn.microsoft.com/en-us/library/td1esda9(v=vs.80).aspx http://msdn.microsoft.com/en-us/library/td1esda9(v=vs.80).as...