From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Using getch() in DJGPP Date: Sun, 20 Oct 1996 20:34:25 -0700 Organization: Three pounds of chaos and a pinch of salt Lines: 43 Message-ID: <326AEF41.3C69@cs.com> References: <01bbbea6$206725e0$454fb7ce AT default> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp103.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: bitc To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp I'd like to add to what everybody else said on the subject that it's generally a bad idea to mix stdio functions with conio functions. stdio functions (printf, puts, scanf, getchar) are line-buffered and use DOS read/write commands, while conio functions (cprintf, cputs, cscanf, getch) use direct writes to video memory and read directly from the BIOS keyboard. So when you use printf() and getch() together, you are in essence mixing apples and oranges, with potentially harmful results no matter how careful you are. My recommended solution to your problem: #include int main( void ) { printf( "Hello." ); getchar( ); /* this flushes stdout automatically so you don't need fflush() or a newline */ return 0; } ------- OR ------- #include #include int main( void ) { cprintf( "Hello." ); getch( ); return 0; } -- John M. Aldrich, aka Fighteer I -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS d- s+:- a-->? c++>$ U@>++$ p>+ L>++ E>+ W++ N++ o+ K? w(---) O- M-- V? PS+ PE Y+ PGP- t+(-) 5- X- R+ tv+() b+++ DI++ D++ G e(*)>++++ h!() !r !y+() ------END GEEK CODE BLOCK------