linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Fábio Russo" <russo@bluecup.com.br>
To: Glynn Clements <glynn@gclements.plus.com>,
	simon <simon.guinot@laposte.net>
Cc: linux-C-programming <linux-c-programming@vger.kernel.org>
Subject: Re: buggy_double_use_of _scanf
Date: Mon, 1 Nov 2004 17:03:50 -0200	[thread overview]
Message-ID: <005001c4c045$86334580$2100a8c0@titanio> (raw)
In-Reply-To: 16766.47776.33240.455119@cerise.gclements.plus.com


----- Original Message -----
From: "Glynn Clements" <glynn@gclements.plus.com>
To: "simon" <simon.guinot@laposte.net>
Cc: "linux-C-programming" <linux-c-programming@vger.kernel.org>
Sent: Tuesday, October 26, 2004 6:59 PM
Subject: Re: buggy_double_use_of _scanf


>
> simon wrote:
>
> > I have observe a strange scanf behaviour...
> > when using two successive scanf... the second receive a return character
> >
> > for example :
> >
> > int a;
> > char b;
> >
> > scanf ("%d", &a);
> > fflush (stdin);
> > scanf ("%c", &b);
> > fprintf (stdout, "a : %d\nb : %c\n", a, b);
> >
> > what's the problem ?
>
> What makes you think that there is a problem?
>
> What's the input? If it's a decimal number followed by newline, the
> first scanf() will return the parsed number, the second will return
> the newline.


The problem, I beleve is in the fflush function. I Have the same behaviour
with this source code,
but when I put a additional scanf in the line, all works fine -;)

Now I ask:
Why the fflush function did not remove the new line caracter when it should
?

it´s all folks !!!

        Russo.


-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2004-11-01 19:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-26 12:42 buggy_double_use_of _scanf simon
2004-10-26 20:59 ` Glynn Clements
2004-11-01 19:03   ` Fábio Russo [this message]
2004-11-02  3:44     ` Glynn Clements
  -- strict thread matches above, loose matches on Subject: below --
2004-11-01 22:25 Huber, George K RDECOM CERDEC STCD SRI

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='005001c4c045$86334580$2100a8c0@titanio' \
    --to=russo@bluecup.com.br \
    --cc=glynn@gclements.plus.com \
    --cc=linux-c-programming@vger.kernel.org \
    --cc=simon.guinot@laposte.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).