delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/27/18:47:50

From: Sunil Rao <sunil AT raos DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: gets
Date: Wed, 27 May 1998 22:27:58 +0100
Organization: Sunil Rao's Wonder Machine
Distribution: world
Message-ID: <LFPfCUAeVIb1EwVG@raos.demon.co.uk>
References: <1998052404332600 DOT AAA20938 AT ladder03 DOT news DOT aol DOT com>
NNTP-Posting-Host: raos.demon.co.uk
MIME-Version: 1.0
Lines: 31
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <1998052404332600 DOT AAA20938 AT ladder03 DOT news DOT aol DOT com>, Peleg79593
<peleg79593 AT aol DOT com> writes
>Okay, so I want to use
>
>gets(x);

no, you don't. gets() is EVIL. use fgets() instead...

>So I add fflush(stdin)

you don't want to do this either... it's undefined.

>before and after all of my buffered inputs.  Same problem.  So, then, I put:
>
>gets(trash);
>
>before every 
>
>gets(x);
>
>and, voila, it works.  What gives here?  Am I doing something wrong, or is this
>an acceptable way to clear the buffer?  

no, it's not. your descriptio of your problem doesn't tell much. maybe
you ought to post some of your code.

-- 
Check out the ALL-NEW alt.comp.lang.learn.c-c++ FAQ list @
<http://www.raos.demon.co.uk/acllc-c++/faq.html>

* ORU WHISKY, ORU MASALA DOSA... MIND IT!

- Raw text -


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