The OpenD Programming Language

readf

Reads formatted data from stdin using std._format.formattedRead.

  1. uint readf(A args)
  2. uint readf(const(char)[] format, A args)
    uint
    readf
    (
    A...
    )
    (
    scope const(char)[] format
    ,
    auto ref A args
    )

Parameters

format const(char)[]

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

args A

Items to be read.

Return Value

Type: uint

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.

Examples

// test.d
void main()
{
    import std.stdio;
    foreach (_; 0 .. 3)
    {
        int a;
        readf!" %d"(a);
        writeln(++a);
    }
}
% echo "1 2 3" | rdmd test.d
2
3
4

Meta