readfln

fnuint readfln(alias format, Data...)(auto ref Data data)

Reads a line from stdin and parses it using formattedRead.

Parameters

formatThe format string. When passed as a compile-time argument, the string will be statically checked against the argument types passed.
dataItems to be read.

Returns

Same as formattedRead: the number of variables filled. If the

input ends early, this number will be less that the number of variables provided.

Example:

// sum_rows.d
void main()
{
   import std.stdio;
   int a, b, c;
   while (readfln("%d %d %d", a, b, c) == 3)
   {
       writeln(a + b + c);
   }
}

% cat << EOF > input

1 2 3 4 5 6 7 8 9 EOF % rdmd sum_rows.d < input 6 15 24

fnuint readfln(Data...)(scope const(char)[] format, auto ref Data data)

ditto