Is there a format specifier that always means char string with _tprintf? Is there a format specifier that always means char string with _tprintf? windows windows

Is there a format specifier that always means char string with _tprintf?


The h modifier forces both %s and %S to char*, and the l modifier forces both to wchar_t*, ie: %hs, %hS, %ls, and %lS.


This might also solve your problem:

_TCHAR *message;_tprintf(_T("\n>>>>>> %d") TEXT(" message is:%s\n"),4,message);


You can easily write something like this:

#ifdef _UNICODE#define PF_ASCIISTR    "%S"L#define PF_UNICODESTR  "%s"L#else#define PF_ASCIISTR    "%s"#define PF_UNICODESTR  "%S"#endif

and then you use the PF_ASCIISTR or the PF_UNICODESTR macros in your format string, exploiting the C automatic string literals concatenation:

_tprintf(_T("There are %d ") PF_ASCIISTR _T(" over the table"), 10, "pens");