delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/10/09:52:20

From: "A. Sinan Unur" <asu1 AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: djgpp bug?
Date: Mon, 10 Mar 1997 08:05:05 -0500
Organization: Cornell University
Lines: 23
Sender: asu1 AT cornell DOT edu (Verified)
Message-ID: <33240701.12C3@cornell.edu>
References: <5g0mss$ivc AT nntp DOT novia DOT net> <5g0nmc$k4k AT nntp DOT novia DOT net> <3323F542 DOT 41C6 AT LSTM DOT Ruhr-UNI-Bochum DOT De>
Reply-To: asu1 AT cornell DOT edu
NNTP-Posting-Host: 128
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Thomas Demmer wrote:
> 
> Alaric Dailey wrote:
> >
> >  the following file compiles and runs perfectly under linux gcc and 
> >  Turbo C for dos however when you compile it under djgpp it skips it 
> >skips entering
> >  /*     scanf("%s",out_entryp->keyword);*/
> >         fflush(stdin);  /*this is so the \n gets flushed
> >                           out of the buffer */
> >
> Here is where you most probably fail:
> fgets() gives you an input line+\n\0
> So if you have the keyword "foo", and your user enters
> "foo"<return>,
> out_entry.keyword really is "foo\n".
...
> BTW, fflush(stdin) _may_ be a bad idea. I think I remember
> flushing an input stream is unspecified in ANSI. Any wizard
> knowing this for sure?
> 
i am not a wizard. that said, fflush(stdin) is ANSI. this is mentioned
in the FAQ for comp.lang.c

- Raw text -


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