On Thu, Jun 23, 2011 at 3:16 PM, Walter Bright <span dir="ltr"><<a href="mailto:newshound2@digitalmars.com">newshound2@digitalmars.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">On 6/23/2011 1:03 PM, Jimmy Cao wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
On Thu, Jun 23, 2011 at 2:52 PM, Walter Bright <<a href="mailto:newshound2@digitalmars.com" target="_blank">newshound2@digitalmars.com</a><br></div><div><div></div><div class="h5">
<mailto:<a href="mailto:newshound2@digitalmars.com" target="_blank">newshound2@<u></u>digitalmars.com</a>>> wrote:<br>
<br>
    On 6/23/2011 11:48 AM, Jimmy Cao wrote:<br>
<br>
        But that's not possible (to set it to line-buffering) on Windows, right?<br>
<br>
<br>
    Sure it is, using the usual C functions. This is not a Windows thing, it's a<br>
    C runtime library thing.<br>
<br>
<br></div></div><div class="im">
How do you make it have line-buffering?<br>
It's not possible to set line-buffering in Windows using setvbuf, it seems:<br>
<a href="http://msdn.microsoft.com/en-us/library/86cebhfs(v=vs.71).aspx" target="_blank">http://msdn.microsoft.com/en-<u></u>us/library/86cebhfs(v=vs.71).<u></u>aspx</a><br>
_IOFBF and _IOLBF are the same.<br>
<br>
I think this is the cause of the strange flushing inconsistencies with stdio.d<br>
from my earlier example on Windows.<br>
</div></blockquote>
<br>
I can't say anything about VC++, but dmd on Windows is designed to work with DMC++.<br>
<br>
<a href="http://www.digitalmars.com/rtl/stdio.html#setvbuf" target="_blank">http://www.digitalmars.com/<u></u>rtl/stdio.html#setvbuf</a><br>
</blockquote></div><br><div>On Windows:</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div>import std.stdio;</div><div><br></div><div>extern(C) int getch();</div>

<div><br></div><div>void main()</div><div>{</div><div>    stdout.setvbuf(100, _IOLBUF);</div><div>    string mystr = "Hello\n";</div><div>    fwrite(mystr.ptr, mystr[0].sizeof, mystr.length, stdout.getFP);</div>

<div><br></div><div>    // FPUTC('\n', cast(_iobuf*)stdout.getFP);</div><div><br></div><div>   getch();</div><div>}</div><div><br></div></blockquote>Am I doing anything wrong there? That code as it is does not flush until after a keypress (when the program terminates).  Uncomment the FPUTC call and it does flush before the keypress.