Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #7806

Re: Scanf Problem

From John Gordon <gordon@panix.com>
Newsgroups comp.lang.c
Subject Re: Scanf Problem
Date 2011-07-07 04:29 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <iv3cnl$b0p$1@reader1.panix.com> (permalink)
References <eab46c07-89fa-43e1-a2ec-b44b69fcb80b@x41g2000yqd.googlegroups.com>

Show all headers | View raw


In <eab46c07-89fa-43e1-a2ec-b44b69fcb80b@x41g2000yqd.googlegroups.com> LJ <djtheshowstopper@gmail.com> writes:

> K&R says that the scanf format string may contain ordinary characters,
> which are expected to match the next non-white space character of the
> input stream.

> However when I am reading the date given as 25           /
> 12      /         1988  using scanf( "%d/%d/%d", &day, &month,
> &year ); it is only reading the day. Why is it not reading the month
> and year??

Probably because your input contains spaces which the format string wasn't
told to look for.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Scanf Problem LJ <djtheshowstopper@gmail.com> - 2011-07-06 21:19 -0700
  Re: Scanf Problem John Gordon <gordon@panix.com> - 2011-07-07 04:29 +0000
    Re: Scanf Problem LJ <djtheshowstopper@gmail.com> - 2011-07-06 23:40 -0700
      Re: Scanf Problem Ike Naar <ike@sverige.freeshell.org> - 2011-07-07 07:28 +0000
      Re: Scanf Problem Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-07-07 02:00 -0700
  Re: Scanf Problem lawrence.jones@siemens.com - 2011-07-10 15:32 -0400

csiph-web