Exerpad
🔥 0
0 XP
Exercise 3 · Chapter: Input & Type ConversionRequired+50 XP

Fix the Input

The code below is supposed to read a name and print Hi, {name}!, but it has some bugs. Can you fix them?

Hints:

  • Make sure the string variable is mutable.
  • Don't forget to trim the input!
  • Check that read_line is called correctly.
Expected output
Hi, Sam!
rust
use std::io;

fn main() {
let input = String::new();
io::stdin().read_line(&input).unwrap();
println!("Hi, {}!", input);
}
Output
Run your code to see the output here.