The following program<div><br></div><div><a href="http://hpaste.org/fastcgi/hpaste.fcgi/view?id=8445#a8445">http://hpaste.org/fastcgi/hpaste.fcgi/view?id=8445#a8445</a></div><div><br></div><div>should echo the ASCII code of each character the user types, on the fly, with no line buffering whatsoever.</div>
<div><br></div><div>But it doesn&#39;t. At least not under Windows&#39;s cmd, and even less with msys.</div><div><br></div><div>Under Windows, I have to press enter before anything is printed to the screen. It then always prints 71 (that&#39;s upper G, no idea where that comes from), and then blocks. Pressing enter again prints the codes of all characters typed, except the first one, following by the two codes of the linefeeds. So e.g. when I type &quot;abc&quot; ENTER, I get 71, then hitting ENTER again, I get 98 99 10 10.</div>
<div><br></div><div>Under msys, it just ignores both the <span class="Apple-style-span" style="font-family: -webkit-monospace; font-size: 14px; white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">hSetBuffering and <span class="n">hSetEcho, <font class="Apple-style-span" face="arial, helvetica, sans-serif">but when hitting enter, it at least prints the codes correctly.</font></span></span></div>
<div><font class="Apple-style-span" face="-webkit-monospace" size="4"><span class="Apple-style-span" style="font-size: 14px; white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br>
</span></font></div><div>How does it behave under OSX and Linux? Is this a bug or am I doing something wrong?</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div>