Browse - Programming Tips - How do I use _snprintf_s() and why is it crashing?

Date: 2010mar17
Language: C/C++

Q.  How do I use _snprintf_s() and why is it crashing?

A.  The regular way to is it is:

char buf[1000]; _snprintf_s(buf, sizeof(buf), _TRUNCATE, ...);
But this crashes More info: http://connect.microsoft.com/VisualStudio/feedback/details/289013/snprintf-s-causes-array-out-of-bounds-write-when-the-truncate-flag-is-used-for-count So modify your stdlib.h file as explained there or use _snprintf() like this:
_snprintf(buf, sizeof(buf), ...);