delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/01/07/12:21:27

From: "Peter Daniel Davies" <grobe AT globalnet DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: RHIDE exits program without asking for input
Date: Thu, 7 Jan 1999 16:58:07 -0000
Lines: 30
Message-ID: <772p3t$3se$1@newnews.global.net.uk>
References: <36944202 DOT 4CA9A0F3 AT northcoast DOT com>
NNTP-Posting-Host: 195.147.221.49
X-Newsreader: Microsoft Outlook Express 4.71.1712.3
X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

>#include <stdio.h>
>
>int main()
>{
> int c;
>
> c=getchar();
> while (c != EOF){
>   putchar(c);
>   c=getchar();
>   }
> return 0;
>}


If you have any characters still in the keyboard buffer (ie: EOF) then the
program will exit straight away.
kbhit() returns a true value if there is a character waiting in the keyboard
buffer otherwise it returns a false value.

CODE SNIPPET

#include <pc.h>

while(kbhit())
    getch();

Hope this helps.


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019