Last active
March 8, 2024 10:50
-
-
Save brendanashworth/121e9b886fe9bf737654 to your computer and use it in GitHub Desktop.
Rust: reading lines from STDIN and printing them back to console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io; | |
fn main() { | |
// Iterate over the lines in io::stdin() | |
for line in io::stdin().lines() { | |
// Now print the line (line.unwrap() first) via the println!() macro | |
println!("{}", line.unwrap()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It has nothing to do with rust but the program is not hanging it is listenings to standard input ( your keyboard) you can type things and to stop it listening you type ctrl-d.