Mail Archives: djgpp/1998/11/15/06:30:33
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 -