[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 08:07:45 +0200, Egon Andersen, Talura wrote:
>Peter Seidler wrote:
>> 
>> Hej
>> 
>> Kunne en eller anden venlig sjæl fortælle mig, hvordan man flusher stdin.
>> Jeg læser med et bestemt interval det første tegn fra stdin. Derefter vil
>> jeg gerne flushe den.
>> Når jeg så venter en stykke tid og læser igen, kan jeg altså være sikker på,
>> at det tegn jeg læser er tastet i det tidsrum, hvor programmet har sovet.
>> fflush(stdin) virker ikke, men stdin er vel heller ikke en output / updtate,
>> men en input stream.
>> 
>> --
>>         Peter Seidler
>
>Hvis jeg har forstået problemet korrekt, så ønsker du at anvende det
>første tegn der er indtastet i det valgte tidsrum og du vil 'slette'
>resten.
>getchar() læser et tegn ad gangen.
>
>/* read first character */
>mychar = getchar();
>/* flushing characters */
>if(mychar != EOF) while(getchar() != EOF);
>
>Okay, det er ikke en flush, men virkningen bliver den samme skulle jeg
>mene.

Præcis det jeg mente. Jeg tænkte bare, om der var et kald, der gjorde dette.
Efter Frank Damgaards svar mht. at stdin jo kan være en fil, kan jeg godt se
problemet i at flushe. Man kunne dog checke at stdin var en tty først
(hvilket jeg alligevel gør).
Men man kan altså ikke tømme stdin eller en anden input stream med et enkelt
kald?

>
>/Egon
>


-- 
	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] *