[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] Flushing af stdin



On Tue, 30 May 2000 18:54:20 +0200, Frank Damgaard wrote:
>In article <sslug@sslug> you wrote:
>
>> Ok så,
>> ----------
>> int ch;
>> for (;;) {
>> 	/* Det første tegn indtastet i løbet af de sidste 2 sek. læses. */
>> 	ch = getchar();
>> 	/* Her flusher vi så stdin. (Det ville vi i hvert fald gerne). */
>> 	/* Og så sover vi mens stdin måske fyldes lidt op igen. */
>> 	sleep(2);
>> }
>
>Jeg vil foreslå at du bruger en løkke med  select() og så read().
>
>....
>
>> Og det er meget muligt, det ikke giver mening, men er det muligt?
>> En eller anden foreslog:
>
>> 	if (ch != EOF)
>> 		while (getchar() != EOF)
>
>> og det er sådan set præcis det jeg gerne vil - bare med et enkelt kald.
>> Hvis man ikke kan det bruger jeg bare ovenstående.
>
>Bortset fra at så er input slut, og der er ikke mere at komme efter,
>så hvorfor overhovedet lave en "flush/purge" ?

Nej, men efter sleep() kan det jo godt ske, der er noget at komme efter igen
ikke?
Programmet fungerer kun interaktivt (tetris), og der er forhåbentlig aldrig
nogen, der spiller tetris med
	cat control > tetris

-- 
	Peter Seidler


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *