From: "Martin Ambuhl" Newsgroups: comp.os.msdos.djgpp Subject: Re: gets Date: Sun, 24 May 1998 01:21:57 -0400 Organization: Nocturnal Aviation Lines: 40 Message-ID: <6k8aft$ha1@news-central.tiac.net> References: <1998052404332600 DOT AAA20938 AT ladder03 DOT news DOT aol DOT com> NNTP-Posting-Host: p15.tc2.newyo.ny.tiac.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Peleg79593 wrote in message <1998052404332600 DOT AAA20938 AT ladder03 DOT news DOT aol DOT com>... :Okay, so I want to use : :gets(x); ======== No, you don't. Use fgets(x, sizeof x, stdin); /* for staticly allocated x */ or with the size_t argument otherwise specified. ======== : :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) ======== Don't invoke undefined behavior. fflush is defined for output streams, not input files, even in GCC. ======== :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? ====== Post the real code. Your description makes it sound like you have misdiagnosed the problem. ====== : : :