In my code (strict C, not C ++) I use vsnprintf as follows:
char* buf = NULL; size_t sz; sz = vsnprintf( buf, 0, format, args);
But the MS Visual C ++ compiler (MSVS10) warns:
warning C4996: 'vsnprintf': This function or variable may be unsafe. Consider using vsnprintf_s instead.
However, vsnprintf_s does not have a great function, which, when you pass NULL to the buffer, will describe how much data would be printed. Instead, it is documented to return -1 .
I feel that I am using vsnprintf safe manner, determining the required size and the recommended replacement of vsnprintf_s not the same.
Am I missing a better / smarter way to use vsnprintf_s ??
source share