stdout - autoflushing

John Colvin john.loughran.colvin at gmail.com
Wed Dec 4 15:48:22 PST 2013


On Tuesday, 3 December 2013 at 21:23:19 UTC, Ali Çehreli wrote:
> On 12/03/2013 12:36 PM, Benji wrote:
>> On Tuesday, 3 December 2013 at 19:33:47 UTC, Ali Çehreli wrote:
>>> On 12/03/2013 09:12 AM, Benji wrote:
>>>> Hello,
>>>> in order to have correctly displayed output (before reading 
>>>> something
>>>> from stdin),
>>>> I must call stdout.flush().
>>>
>>> I am surprised that you need that. What is your platform?
>>>
>>> Normally, stdin and stdout are "tied". Reading from stdin 
>>> flushes
>>> stdout automatically.
>>>
>>> Ali
>>
>> I am using Xubuntu, 64bit, and GDC as compiler
>
> I've known this to be the case for cin and cout of C++. So, 
> I've been assuming that to be universally true. Apparently not 
> for C and D behavior is based on C. I wish std.stdio gave us 
> C++'s 'tie'.
>
> Ali
>
> P.S. This makes some of the examples at ddili.org incorrect as 
> I never call flush. :-/

The 'tie' is sometimes convenient, but it's not good in Unix 
style stdin/stout piping or similar situations with lots of 
simultaneous input and output.


More information about the Digitalmars-d-learn mailing list