Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ike Naar <ike@sverige.freeshell.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Scanf Problem |
| Date | 2011-07-07 07:28 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <slrn3vfsj1ao0k.g6i.ike@sverige.freeshell.org> (permalink) |
| References | <eab46c07-89fa-43e1-a2ec-b44b69fcb80b@x41g2000yqd.googlegroups.com> <iv3cnl$b0p$1@reader1.panix.com> <77b19eb4-22ee-47d8-8760-1ebd1c5c4622@d22g2000yqn.googlegroups.com> |
On 2011-07-07, LJ <djtheshowstopper@gmail.com> wrote: > On Jul 7, 9:29?am, John Gordon <gor...@panix.com> wrote: >> In <eab46c07-89fa-43e1-a2ec-b44b69fcb...@x41g2000yqd.googlegroups.com> LJ <djtheshowstop...@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. > > That doesn't answer my question, '/' should match the next non- > whitespace character and in input that character is '/' only, so scanf > shud read all the three dates It does answer your question; you should tell scanf to skip the whitespace. Read your scanf documentation. Hint: "d% / %d / %d".
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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