View source code
Display the source code in std/stdio.d from which thispage was generated on github.
Report a bug
If you spot a problem with this page, click here to create aBugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.Requires a signed-in GitHub account. This works well for small changes.If you'd like to make larger changes you may want to consider usinglocal clone.
Function std.stdio.readfln
Reads a line from stdin
and parses it using formattedRead
.
uint readfln(alias format, Data...)(
auto ref Data data
);
uint readfln(Data...)(
scope const(char)[] format,
auto ref Data data
);
Parameters
Name | Description |
---|---|
format | The format string. When passed as a compile-time argument, the string will be statically checked against the argument types passed. |
data | Items 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
Authors
Walter Bright, Andrei Alexandrescu, Alex Rønne Petersen
License
Copyright © 1999-2025 by the D Language Foundation | Page generated by ddox.