Well, this is tricky! :-) I have always used vsnprintf()
] to do the job by specifying
and zero as the first two parameters. If you look at the documentation and check out what it says about the return value you will see that this is perfectly valid usage of the function!
EDIT: The same function in the VC++ crt isn't compatible with the linux version, the windows version returns -1 when the output needs to be truncated. See the docs: vsnprintf()