Date: Sun, 15 Nov 1998 13:05:26 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: "G.B.Rotman" cc: djgpp AT delorie DOT com Subject: Re: scanf/gets bug? In-Reply-To: <364B050E.2140660@stud.biol.ruu.nl> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com On Thu, 12 Nov 1998, G.B.Rotman wrote: > A *portable* way of making sure the newline is not left in the buffer > is to force `scanf' to consume it as well, like this: > > scanf ("%d\n", &x); > > This doesn't seem to work, put a line like this > one in and scanf waits until it has been given > two integers but it still leaves the newline in the > buffer. It works for me. I actually tried that line before replying the other day. So maybe the actual program you are trying is a bit different, and needs somewhat different format. > Isn't there a proper way to empty the buffer? No, not in a portable way. And I don't think this is even required in this case, anyway.