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), ...);