The OpenD Programming Language

readfln

Reads a line from stdin and parses it using std.format.read.formattedRead.

  1. uint readfln(Data data)
    uint
    readfln
    (
    alias format
    Data...
    )
    (
    auto ref Data data
    )
  2. uint readfln(const(char)[] format, Data data)

Parameters

format

The format string. When passed as a compile-time argument, the string will be statically checked against the argument types passed.

data Data

Items to be read.

Return Value

Type: uint

Same as formattedRead: the number of variables filled. If the input ends early, this number will be less that the number of variables provided.

Examples

// 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

Meta