using readf in D

Carlos checoimg at gmail.com
Sat Apr 20 07:17:48 PDT 2013


On Saturday, 20 April 2013 at 14:00:50 UTC, Chris Cain wrote:
> On Saturday, 20 April 2013 at 12:52:30 UTC, Carlos wrote:
>> First it takes two reads for the first input from the user and 
>> second it only calculates tcsleep.
>
> Oh, I see what you mean by this now. You were describing the
> problem (I thought you were telling us what the program does).
>
> Ok, so this will fix the problem:
>
>      readf(" %d", &minsleep);
>
> and
>
>      readf(" %d", &minsit);
>
> Notice, the space is before the %d instead of after. The space
> means "eat all of the whitespace before the next input". So, as
> you can see, it has to "take two reads" because it's waiting for
> some non-whitespace information. If you kept hitting enter (or
> inputting spaces), you'd see that it'd keep prompting you.

Ok now it works perfectly. Thanks you very much Chris Cain!
I was using it with space before and after because in the book 
"The D Progamming language" by Andrei Alexandrescu page 22 it was 
using it that way but I didnt read everything maybe I missed that 
detail.


More information about the Digitalmars-d mailing list