The format string. When passed as a compile-time argument, the string will be statically checked against the argument types passed.
Items to be read.
Same as formattedRead: The number of variables filled. If the input range r ends early, this number will be less than the number of variables provided.
// test.d void main() { import std.stdio; auto f = File("input"); foreach (_; 0 .. 3) { int a; f.readf!" %d"(a); writeln(++a); } }
% echo "1 2 3" > input % rdmd test.d 2 3 4
static import std.file; auto deleteme = std.file.deleteme(); std.file.write(deleteme, "hello\nworld\ntrue\nfalse\n"); scope(exit) std.file.remove(deleteme); string s; auto f = File(deleteme); f.readf!"%s\n"(s); assert(s == "hello", "["~s~"]"); f.readf("%s\n", s); assert(s == "world", "["~s~"]"); bool b1, b2; f.readf("%s\n%s\n", b1, b2); assert(b1 == true && b2 == false);
Reads formatted data from the file using std._format.formattedRead.