using readf in D

Chris Cain clcain at uncg.edu
Sat Apr 20 06:58:10 PDT 2013


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.


More information about the Digitalmars-d mailing list