By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,008 Members | 1,235 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,008 IT Pros & Developers. It's quick & easy.

ostream_iterator<wstring, wchar_t>(wcout,"\n"))

P: n/a
There's probably something obvious I'm missing here, but I can't seem to
figure out how to get this to work:
ostream_iterator<wstring, wchar_t>(wcout,"\n"));

When I try to compile it, I get an error telling me it doesn't like the
char[2]. wcout.widen('\n') doesn't work here because it wants a string. Is
there a way to make this work?

--
NOUN:1. Money or property bequeathed to another by will. 2. Something handed
down from an ancestor or a predecessor or from the past: a legacy of
religious freedom. ETYMOLOGY: MidE legacie, office of a deputy, from OF,
from ML legatia, from L legare, to depute, bequeath. www.bartleby.com/61/
Feb 1 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Steven T. Hatton schrieb:
There's probably something obvious I'm missing here, but I can't seem to
figure out how to get this to work:
ostream_iterator<wstring, wchar_t>(wcout,"\n"));

When I try to compile it, I get an error telling me it doesn't like the
char[2]. wcout.widen('\n') doesn't work here because it wants a string. Is
there a way to make this work?


Did you try: L"\n"?

This...

std::ostream_iterator<std::wstring, wchar_t>(std::wcout, L"\n");

...compiles fine.

Thomas
Feb 1 '06 #2

P: n/a
"Steven T. Hatton" <ch********@germania.sup> wrote in message
news:EP******************************@speakeasy.ne t
There's probably something obvious I'm missing here, but I can't seem
to figure out how to get this to work:
ostream_iterator<wstring, wchar_t>(wcout,"\n"));

When I try to compile it, I get an error telling me it doesn't like
the char[2]. wcout.widen('\n') doesn't work here because it wants a
string. Is there a way to make this work?


"\n" is a char string literal. You want L"\n" for a wchar_t string literal.

--
John Carson
Feb 1 '06 #3

P: n/a
John Carson wrote:
"Steven T. Hatton" <ch********@germania.sup> wrote in message
news:EP******************************@speakeasy.ne t
There's probably something obvious I'm missing here, but I can't seem
to figure out how to get this to work:
ostream_iterator<wstring, wchar_t>(wcout,"\n"));

When I try to compile it, I get an error telling me it doesn't like
the char[2]. wcout.widen('\n') doesn't work here because it wants a
string. Is there a way to make this work?


"\n" is a char string literal. You want L"\n" for a wchar_t string
literal.

Uh,..., as it turns out, that is an intelligent answer to a stupid question.
There were spiders in the source data! When I loaded it into a buffer of
the One True Editor, I saw immediately the DOS encoding problem. A simple
conversion to UTF-8 solved all my problems.

Thanks for the advice. The next time I get stupid and try to do things the
hard way, it might not be quite so hard. :-/
--
NOUN:1. Money or property bequeathed to another by will. 2. Something handed
down from an ancestor or a predecessor or from the past: a legacy of
religious freedom. ETYMOLOGY: MidE legacie, office of a deputy, from OF,
from ML legatia, from L legare, to depute, bequeath. www.bartleby.com/61/
Feb 2 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.