Getch() Problem: C vs D

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jan 9 05:10:30 PST 2017


On Sunday, 8 January 2017 at 21:19:15 UTC, LouisHK wrote:
> And works fine, but the D version below nothing happens when I 
> hit ESCAPE:

Different runtimes are free to line buffer data, meaning getch 
won't actually see anything until you hit enter.

(Actually, the operating system does the buffering unless the 
runtime specifically asks it not to.)

Looks like your C library (gcc? asks the OS not to buffer, and 
the D (digital mars or Microsoft, DM on 32 bit, MS on 64 bit) 
turn it off.

Best solution is to skip those C library functions and do it 
yourself with the OS-level calls. Then you can turn it off and 
actually control the buffering behavior.


More information about the Digitalmars-d-learn mailing list