I wrote the following code to check if the user entered "Hi" and in that case it would print "Bye", but every time I run the program it just prints "Hi".
use std::io;
fn main() {
let mut input = String::new();
println!("Say something:");
match io::stdin().read_line(&mut input) {
Ok(_) => {}
Err(e) => println!("Error: {}", e),
};
if input == "Hi" {
println!("Bye");
}
}
Aucun commentaire:
Enregistrer un commentaire