473,327 Members | 2,103 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

mixing of std::cout and std::wcout

Hi,

can I mix output to cout and wcout? It seems that if I write to cout
first it works fine but if I start with wcout the output to cout
vanishes. I assume that is has to do with the initialization of
standard output, right?

#include <iostream>

using namespace std;

int main(int argc, char *argv[]){
wcout<<L"wcout"<<endl; //(*)
cout<<"cout"<<endl;
wcout<<L"wcout"<<endl;
cout<<"cout"<<endl;
}

This gives

wcout
wcout

but if I comment out the line marked (*) the output is

cout
wcout
cout

Is that standard or is my compiler ("gcc version 4.1.2 20061115
(prerelease) (SUSE Linux)") buggy?

Ralf
Jul 4 '07 #1
2 7645
Ralf Goertz <r_******@expires-2006-11-30.arcornews.dewrote:
#include <iostream>

using namespace std;

int main(int argc, char *argv[]){
wcout<<L"wcout"<<endl; //(*)
cout<<"cout"<<endl;
wcout<<L"wcout"<<endl;
cout<<"cout"<<endl;
}

This gives

wcout
wcout
Using VS 2005, I get the expected output:

wcout
cout
wcout
cout
Is that standard or is my compiler ("gcc version 4.1.2 20061115
(prerelease) (SUSE Linux)") buggy?
I would say it might be a problem with the compiler, or at least with
the iostream implementation. I recall hearing something about gcc not
handling wide streams correctly.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Jul 5 '07 #2
Marcus Kwok wrote:

I would say it might be a problem with the compiler, or at least with
the iostream implementation. I recall hearing something about gcc not
handling wide streams correctly.

Meanwhile I found out that this behaviour is intended. Mixing wide and
non wide streams is not considered standard. Although one might argue
that the asymmetric gcc implementation is somewhat awkward.

http://gcc.gnu.org/ml/gcc-bugs/2006-05/msg01196.html

Thanks anyway,

Ralf
Jul 6 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alex Mizrahi | last post by:
Hello, All! i admit that it's better to ask questions connected with atl/mfc classes in special newsgroups, but seems like people there are interested more in discussing stuff like MFC GUI than...
7
by: jalkadir | last post by:
WinXP P3 MinWing-GCC-3.4.3 When compiling the program below, I get a message that reads: wcout' is not a member of `std' What am I doing wrong? This message popping up too often!! >:( TIA
4
by: Ioannis Vranos | last post by:
Will "STL .NET" of VS 2005 include a fully managed std::string? -- Ioannis Vranos
3
by: Steven T. Hatton | last post by:
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...
1
by: Andy | last post by:
Can I mix wide and narrow character output to stdout? I seem to remember hearing this was not supported before but I can't find any reference to such a restriction now I actually need to do it! It...
10
by: Jeffrey Walton | last post by:
Hi All, I've done a little homework (I've read responses to similar from P.J. Plauger and Dietmar Kuehl), and wanted to verify with the Group. Below is what I am performing (Stroustrup's...
1
by: Angus | last post by:
Hello I can do this: std::wstring strHello; std::cout << strHello.c_str() << std::endl; But not this:
2
by: year1943 | last post by:
There was the same topic not so long ago, but as I see it stays w/o answer:...
44
by: Ioannis Vranos | last post by:
Has anyone actually managed to print non-English text by using wcout or wprintf and the rest of standard, wide character functions?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.