www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/15/06:30:33

Date: Sun, 15 Nov 1998 13:05:26 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: "G.B.Rotman" <g DOT b DOT rotman AT stud DOT biol DOT ruu DOT nl>
cc: djgpp AT delorie DOT com
Subject: Re: scanf/gets bug?
In-Reply-To: <364B050E.2140660@stud.biol.ruu.nl>
Message-ID: <Pine.SUN.3.91.981115130505.1381E-100000@is>
MIME-Version: 1.0
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.

- Raw text -


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