Mail Archives: djgpp/1997/03/10/09:52:20
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 -