From: "A. Sinan Unur" Newsgroups: comp.os.msdos.djgpp Subject: Re: simple getch() Date: 7 Sep 2002 21:13:23 GMT Organization: Cornell University Lines: 54 Sender: asu1 AT cornell DOT invalid (on pool-141-149-206-20.syr.east.verizon.net) Message-ID: References: NNTP-Posting-Host: pool-141-149-206-20.syr.east.verizon.net X-Trace: news01.cit.cornell.edu 1031433203 1898 141.149.206.20 (7 Sep 2002 21:13:23 GMT) X-Complaints-To: usenet AT news01 DOT cit DOT cornell DOT edu NNTP-Posting-Date: 7 Sep 2002 21:13:23 GMT User-Agent: Xnews/5.04.25 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "MrShifty" wrote in news:wa7e9.146658$Rx4 DOT 1541323 AT twister DOT tampabay DOT rr DOT com: > When I run this program it doesn't beep until I hit escape. At that > point it beeps however many times that I hit the spacebar. cout is buffered by default. it is not a good idea to intermix conio functions with the standard library routines. > Here is the code: > > #include > #include > > int main(){ > int ch; > > while(ch != 27){ ch is unitialized in this test. > ch = getch(); > if(ch == 32) > cout << '\a'; > } > > return 0; > } try the following: #include #include int main(void) { int c; while((c = getch()) != 27) { if(c == ' ') { putch('\a'); __dpmi_yield(); } } return 0; } -- A. Sinan Unur asu1 AT c-o-r-n-e-l-l DOT edu Remove dashes for address Spam bait: mailto:uce AT ftc DOT gov