How To Read From Stdin Rust

[Solved] How To Read From Stdin Rust | Rust - Code Explorer | yomemimo.com
Question : how to read from stdin rust

Answered by : jimmy-hypi

use std::io;
let mut input = String::new();
match io::stdin().read_line(&mut input) { Ok(n) => { println!("{} bytes read", n); println!("{}", input); } Err(error) => println!("error: {}", error),
}Run

Source : https://doc.rust-lang.org/std/io/struct.Stdin.html#method.read_line | Last Update : Fri, 28 Feb 20

Answers related to how to read from stdin rust

Code Explorer Popular Question For Rust