Peter 'Shaggy' Haywood
4/1/2011 2:03:00 AM
Groovy hepcat Owner was jivin' in comp.lang.c on Tue, 29 Mar 2011 3:13
am. It's a cool scene! Dig it.
> On Mon, 28 Mar 2011 14:05:15 +0100, Mark Bluemel wrote:
>
>> On 03/28/2011 02:01 PM, Ben Bacarisse wrote:
>>> ... You
>>> can keep trying various options in the hope of hitting the correct
>>> one eventually (the odds are not good) or you can follow through
>>> exactly what it is that your code is doing, step by step.
>>
>> Or you can post your attempts up to a newsgroup and hope someone will
>> fix them for you, so that you don't fail your assignment...
>>
>> "The Gods do not protect fools. Fools are protected by more capable
>> fools." (Larry Niven)
>
> I finally got it
>
> while (scanf("%*s %*s %d%*s\n", &daytotal) == 1)
Yes, but do you actually understand why that works? If not, then
perhaps you should review your C reference manual. What does the %d
conversion specifier of scanf() match? And what is the third field of
your input? So how does %d treat the third field of your input? And so,
what is left unread at the end of the line after the %d has matched? So
what, then, is the next scanf() call reading, and what effectively is
the third field of that?
--
Dig the sig!
----------- Peter 'Shaggy' Haywood ------------
Ain't I'm a dawg!!