I'm assuming that a tstring is simply a basic_string<TCHAR>.
If that's the case, then you should wrap all your string literals using the _T() or _TEXT macro. Otherwise, if you never plan on compiling you code for UNICODE target then don't bother with tstring, just use string.
That aside, printf() style formatting is done in C++ using streams, like cin, cout, fstream's etc...
basic_string<> can have I/O streams as well:
These have cooresponding typedef's just like basic_string<> does:
* stringstream (for type char)
* wstringstream (for type wchar_t)
* tstringstream (don't know if this is typedef'd for you or not)
And there are input only and output only versions of each of these like istringstream and ostringstream.
Here is some code that defines the tstring and tostringstream types and uses them.
Your alternative is to use _stprintf() on a TCHAR buffer and assign that to your tstring.
//#define _UNICODE // enable to test as a UNICODE build
using namespace std;
// typedef a TCHAR string and ostringstream types
allocator<TCHAR> > tstring;
allocator<TCHAR> > tostringstream;
// define "tcout" to be either cout or wcout depending
// on the true type of TCHAR
#define tcout wcout
#define tcout cout
ts_out << _T("double val = ") << 1234.5678 << endl
<< _T("long val = ") << 69L << endl
<< _T("long val in hex = 0x") << hex << 105L << dec << endl;
tstring results = ts_out.str();
tcout << results;