Reading from stdin()

Hi, everyone.
What's the latest and least verbose way to

  • Read from stdin until '\n' (or line break) is detected and storing into a string? For example:

string input = readln();

  • Read until EOF is reached and storing it into a string? For example:
string result;
foreach(string line; lines(stdin))
    result ~= line;
1 Like

To read a line, Stdin in std::io - Rust.

Till EOF, Read in std::io - Rust (Stdin implements Read, so this method is available if Read is imported).

3 Likes