Microsoft’s <tchar.h> defines _stprintf as swprintf if _UNICODE is defined, and sprintf if not. But these functions take different arguments! In swprintf, the second argument is the buffer size, but sprintf doesn’t have this.
Did somebody goof? If so, this is a big one. How can I use _stprintf in my programs, and have them work with and without _UNICODE?
You’re seeing parallel evolution here.
swprintfis a latecomer to standard C, after it was discovered that (A) 8 bits is insufficient for text and (B) you should pass buffer sizes along with buffers.TCHARis a microsoft idea to unify ASCII and Unicode APIs. They dropped the ball, missing point (B). The properTCHARsolution should have been to define_stprintfas eitherswprintforsnprintf.The solution is then to simply wrap
<tchar.h>and do this yourself.