I tried to write a bit of code which reads a name from stdin and prints it. The problem is the line breaks immediately after printing the variable and the characters followi
Use .trim() to remove whitespace on a string. This example should work.
use std::io;
fn main() {
println!("Enter your name:");
let mut name = String::new();
io::stdin().read_line(&mut name).expect("Failed To read Input");
println!("Hello '{}'!", name.trim());
}
There also trim_start() and .trim_end() if you need to remove whitespace changes from only one side of the string.