[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
 

getchar buffer.



Hej cprog

    Jeg er stødt ind i et underligt problem der går som følger:
....
....
void foo()
  {
  char str[10];
  ...
  cin >> str;
  ....
   }

void main()
   {
   char ch='a';

   do
      {
      foo();
      ch=getchar();
      }
   while (ch!='n')
   }

Det burde køre foo() indtil der tastes 'n' ved getchar() kaldet. Men,
det virker som om det afsluttende '\n' fra cin i foo() "preller af", og
bliver opfattet som input af getchar(). Hvorfor det ?!? Findes der en
buffer for getchar(), og hvis ja: hvordan tømmer jeg den. Det skal lige
siges at jeg har modificeret getchar() således at den ikke venter på at
man trykker enter, men tager input char for char, og her, kun tager en
char og sender den videre.

Regards
    Frederik Treue



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:07 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] *