linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Glynn Clements <glynn@gclements.plus.com>
To: jesse@ajp-services.net
Cc: linux-c-programming@vger.kernel.org
Subject: Re: Help: need to prevent infinite loop
Date: Sun, 22 Jan 2006 10:20:44 +0000	[thread overview]
Message-ID: <17363.23676.751524.480464@cerise.gclements.plus.com> (raw)
In-Reply-To: <43CC996D.4050100@ajp-services.net>


Jesse Ruffin wrote:

> The problem is a general one that will affect many non digit characters.
> 
> scanf() on my computer returns 0, an early match error. But what you
> probably don't expect, and I can't find in the info or man pages, is
> that glibc scanf seems to unget() the input that it has read.

It doesn't "unget" anything, it simply doesn't consume anything.

More generally, [f]scanf() only consumes the data which actually
matches the fields in the format string. The return value tells you
how many fields were assigned; if the return value is zero, nothing is
assigned and nothing is consumed.

-- 
Glynn Clements <glynn@gclements.plus.com>

  parent reply	other threads:[~2006-01-22 10:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-17  4:36 Help: need to prevent infinite loop Shriramana Sharma
2006-01-17  7:14 ` Jesse Ruffin
2006-01-18 16:24   ` Shriramana Sharma
2006-01-18 16:33     ` Steve Graegert
2006-01-22 10:20   ` Glynn Clements [this message]
2006-01-22 11:28     ` Jesse Ruffin
2006-01-23  5:57       ` Jesse Ruffin

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=17363.23676.751524.480464@cerise.gclements.plus.com \
    --to=glynn@gclements.plus.com \
    --cc=jesse@ajp-services.net \
    --cc=linux-c-programming@vger.kernel.org \
    /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).