Convert wchar_t to string?

I have wchar_tone that I would like to convert to string. Then the line should be read with stringstream. I looked at it here: http://msdn.microsoft.com/en-us/library/ms235631(v=vs.80).aspx , but none of them return anything useful with stringstream. I am not very good at coding, so I probably missed something very simple.

Thanks in advance!

+3
source share
1 answer

If you really need stringfrom wchar_t*you first need to convert wchar_t*to char*. There are various ways to do this, depending on which compiler you are using. The easiest way is to use wcstombs(), but there are caveats to this. Here is a good discussion on this subject, with some solutions that may inspire you http://www.daniweb.com/software-development/cpp/threads/87362 .

However, you can just use wstringdirectly with wchar_t*, as @ Space_C0wb0y mentioned. If this is what you are looking for, mark his answer correctly.

+5
source

All Articles