From: Bojan Resnik Newsgroups: comp.os.msdos.djgpp Subject: Re: getch() with DJGPP Date: Thu, 06 Apr 2000 17:54:50 +0200 Organization: Public news server of EUnet Yugoslavia Lines: 23 Message-ID: References: <38EC822B DOT 230D4ECE AT cafeetje DOT nl> NNTP-Posting-Host: p-2.65.eunet.yu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: SOLAIR2.EUnet.yu 955036686 23940 213.240.2.65 (6 Apr 2000 15:58:06 GMT) X-Complaints-To: abuse AT EUnet DOT yu NNTP-Posting-Date: 6 Apr 2000 15:58:06 GMT X-Newsreader: Forte Agent 1.6/32.525 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Bart Verbakel wrote: >I am trying to create a loop like this: > >while ( getch() != 'q' ) > printf("Neverending textstring"); > >This is SUPPOSED to put the string to stdout, >until I touch the 'q' key. > >But, compiling this with DJGPP and running it in an DOS-box >under Win98, It does not!! >After each 'printf' it waits for me to press "RETURN" > >How do I solve this problem ??? You misunderstood the getch() function. If a character is waiting in the keyboard queue, it will return it. If it isn't, then it will wait until you press a key. The way to accomplish what you want is to use kbhit(): while ( !kbhit() || (getch() != 'q') ) printf("Neverending textstring");