Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you are doing Windows C/C++ development, you can use the strsafe.h functions (https://learn.microsoft.com/en-us/windows/win32/api/strsafe/). When I wrote C/C++, I found them easier to use than the standard C functions because they handled all of the usual failure cases (buffer too small, integer overflow, etc.). It was also easy to check if there was a failure because all of the functions returned a failure code if something went wrong.

In this case, StringCchCopyW(), or StringCbCopyW() would be a better choice than strcpy.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: