www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - TDPL's use of readf

reply Jeff Merrick <merrick.jd gmail.com> writes:
On page 22 of TDPL, we have the following code:

import std.contracts, std.stdio;
void main(string[] args) {
  // ...
  for (double x; readf(" %s ", &x) == 1; ) {
    // ...
  }
  // ...
}

Using DMD v2.047, I get the following error on the readf call:

  Error: undefined identifier readf, did you mean function readln?

I didn't see this mentioned in the TDPL errata.  Was there a change to the
standard library after the book
went to press?  Or am I doing something wrong?

Thanks,

Jeff
Jun 23 2010
parent Jonathan M Davis <jmdavisProg gmail.com> writes:
Jeff Merrick wrote:

 On page 22 of TDPL, we have the following code:
 
 import std.contracts, std.stdio;
 void main(string[] args) {
   // ...
   for (double x; readf(" %s ", &x) == 1; ) {
     // ...
   }
   // ...
 }
 
 Using DMD v2.047, I get the following error on the readf call:
 
   Error: undefined identifier readf, did you mean function readln?
 
 I didn't see this mentioned in the TDPL errata.  Was there a change to the
 standard library after the book
 went to press?  Or am I doing something wrong?
 
 Thanks,
 
 Jeff
Andrei talked about that on the digitalmars.D list. He forgot to check in the code for it, so it's not in v2.047. However, I believe that he's checked it into the svn version, so readf should be in v2.048 when that comes out. - Jonathan M Davis
Jun 23 2010