Question

wstring ws(L"Press 'q' to end.");
wcout << ws;

error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::wstring' (or there is no acceptable conversion)

This is in a VC++ 2005 Win32 console app, created with default settings... which I think means UNICODE is on? I only just found out cout doesn't seem to support wstring, which seems a bit ugly - is that true? This app interacts with libraries which return wstrings and it might as well be Unicode, is there some project setting I need to change?

Was it helpful?

Solution

Try

wstring ws(L"Press 'q' to end."); 
wcout << ws.c_str(); 

BTW: wchar != wstring

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top