Logo

Programming-Idioms

  • D
  • Rust

Idiom #278 Read one line from the standard input

Read one line into the string line.

Explain what happens if EOF is reached.

let mut buffer = String::new();
let mut stdin = io::stdin();
stdin.read_line(&mut buffer).unwrap();

String is empty if EOF
with Ada.Text_IO;
Line : constant String := Ada.Text_IO.Get_Line;

End_Error is raised if EOF is reached.

New implementation...
< >
programming-idioms.org