I am writing a small conceptual console program with Visual Studio 2008, and I wanted it to output colored text for readability. For coding convenience, I also wanted to make a quick replacement for printf, something where I could write like this:
MyPrintf(L"Some text \1[bright red]goes here\1[default]. %d", 21);
This will be useful because I also create and pass strings in some places, so my strings will contain formatting information.
However, I hit the wall against wsprintf, because I can’t find a function that would let me know the size of the required buffer before passing it to the function. I could, of course, allocate 1 MB to be sure, but that would be ugly, and I would prefer to leave this as a backup solution if I don't find a better way.
In addition, I am also considering the possibility of using std::wstring(I actually look more like a C-guy with little experience in C ++, so now I find a simple-old-w980 -arrays), but it doesn’t have something like wsprintf, where you could build a string with the values replaced in them.
So ... what should I do?
Vilx- source
share