Microsoft has been promoting to use the _s version for the CRT function. Soon, all the non _s version will be deprecated, perhaps two or three more operating system.
As I am trying to comply with Microsoft, I encountered a unexpected behaviour of _tcscpy_s.
If you have a buffer of lets say 24 byte and you would like to copy a 4 byte long string, based on MSDN documentation, you will do this: _tcscpy (dest, 24, src).
The _tcscpy did the correct job, copying the 4 byte of the string and 1 byte of null character to termintate the string. But hey !!! It did additional job, it messed up the data in offset 6 - 24.
Be careful !!!!
Subscribe to:
Post Comments (Atom)
Good to know. Maybe_tcscpy_s copies ALL 24 chars no matter the strlen...
ReplyDelete