Topic: Are cout and cerr syncronised?


Author: Daniel Wicke <wicke@cern.ch>
Date: 2000/04/27
Raw View
Hi,

I am wondering whether cout and cerr are syncronised.
I.e.: Can I rely on

cout << "a";cerr << "b";cout << "c";

to produce "abc" (as long as cout and cerr point to the same console)?

This is the case for the compilers I tested, but is it *defined* in the
standard or have I been lucky?

Best regards
Daniel

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: Dietmar Kuehl <dietmar.kuehl@claas-solutions.de>
Date: 2000/04/28
Raw View
Hi,
In article <3907F42B.5574A423@cern.ch>,
  Daniel Wicke <wicke@cern.ch> wrote:

> I am wondering whether cout and cerr are syncronised.
> I.e.: Can I rely on
>
> cout << "a";cerr << "b";cout << "c";
>
> to produce "abc" (as long as cout and cerr point to the same console)?

No, there is no such guarantee. That is, if an implementation indeed
produces this result, you are actually unlucky because it traps you
into thinking that this is defined behavior.
--
<mailto:dietmar.kuehl@claas-solutions.de>
homepage: <http://www.informatik.uni-konstanz.de/~kuehl>


Sent via Deja.com http://www.deja.com/
Before you buy.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]