tags:

views:

113

answers:

2

Hi

I'm quite sure that it is a stupid issue but it drives me crazy..

how could i print on the console a TCHAR array?

DWORD error = WSAGetLastError();
TCHAR errmsg[512];
int ret = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, error, 0, errmsg, 511, NULL);

i need to print errmsg...

+1  A: 

A Google search revealed this discussion which essentially recommends tprintf.

Jacob
+1  A: 

It depends on what TCHAR is. If you compile with Unicode enabled, TCHAR is defined as wchar_t. Then you can use std::wcout, for example:

std::wcout << L"Error: " << errmsg << '\n';

If Unicode is not enabled, TCHAR is an ordinary char and you can use the ordinary std::cout:

std::cout << "Error: " << errmsg << '\n';
Thomas
thanks a lot :)!
hara