www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/24/00:45:38

From: peleg79593 AT aol DOT com (Peleg79593)
Newsgroups: comp.os.msdos.djgpp
Subject: gets
Lines: 20
Message-ID: <1998052404332600.AAA20938@ladder03.news.aol.com>
NNTP-Posting-Host: ladder03.news.aol.com
Date: 24 May 1998 04:33:25 GMT
Organization: AOL http://www.aol.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Okay, so I want to use

gets(x);

instead of scanf in a bunch of input functions. So I replace all the scanfs.
But, then, the program just skips past the gets(x) without accepting any input
as though there were something still in the buffer.  So I add fflush(stdin)
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?  



- Raw text -


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