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

  • Thread starter Steven T. Hatton
  • Start date
S

Steven T. Hatton

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?
 
J

John Carson

Steven T. Hatton said:
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.
 
T

Thomas J. Gritzan

Steven said:
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::eek:stream_iterator<std::wstring, wchar_t>(std::wcout, L"\n");

...compiles fine.

Thomas
 
S

Steven T. Hatton

John said:
Steven T. Hatton said:
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. :-/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top