www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/30/02:03:16

Xref: news2.mv.net comp.os.msdos.djgpp:4362
From: dmicolet AT u-bourgogne DOT fr (Dominique Micollet)
Newsgroups: comp.os.msdos.djgpp
Subject: fflush(stdin) : does it works ?
Date: 29 May 1996 15:09:07 GMT
Organization: Universite de Bourgogne - Dijon - France
Lines: 25
Message-ID: <4ohpaj$i0j@tempo.univ-lyon1.fr>
NNTP-Posting-Host: satie.u-bourgogne.fr
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I used to get a string with the following :


{
char One_String[80];
....
scanf("%[^\n]",One_String);fflush(stdin);
....
}

The %[^\n] allows to catch any character excepted the new line and then to
get strings with blanks, tabs and so on inside them.
The fflush(stdin) is there to trash the new line, else the next scanf of a
string does not works.
This works fine with many compilers (RS6000, SUN, DEC, PC)

It looks like it does not work with DJGPP V2;
Another try shows me that the stdin is not emptied (spelling ?) at all.

Is this a known behavior of fflush ?  I am a new user of djgpp (an a old one
of C) and do not find anything aout that in the FAQ or the info.

--
Dominique MICOLLET
Email : dmicolet AT satie DOT u-bourgogne DOT fr

- Raw text -


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