Operating System - Linux
1826214 Members
3103 Online
109691 Solutions
New Discussion

Re: how to print wchar_t strings

 
nayeem khan
Occasional Advisor

how to print wchar_t strings

Hi

I need help in priting wchar_t strings
the output i get for the following program is some address

#include
int main()
{
wchar_t temp[]=L"Hello World";
cout<return 0;
}

any info/pointers as how to print

from
nayeem khan
3 REPLIES 3
Dennis Handly
Acclaimed Contributor

Re: how to print wchar_t strings

(These aren't the droids you're looking for. :-)
You shouldn't be using iostream. But instead use stdio.

The reason you get an address is because cout doesn't have a wchar_t insertion operator. You'll need to use wcout.
Then there are N other roadblocks that keeps this from working.

You may instead want to use wcstombs(3) to convert from wide character string to a multibyte string and then just use cout.
nayeem khan
Occasional Advisor

Re: how to print wchar_t strings

Hi Dennis

Thanks for the response...

Another easy way is to use wcout

If we use iostream we have to use wcout instead of cout

#include
int main()
{
wchar_t temp[]=L"Hello World";
wcout<return 0;
}

from
nayeem khan
Dennis Handly
Acclaimed Contributor

Re: how to print wchar_t strings

>If we use iostream we have to use wcout instead of cout

Yes but then you'll only be able to print out ASCII chars.
The N roadblocks are all documented here:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1054305