I am taking a user input and then concatenating that user input with a String.
But output is showing in two different lines. Any method to be placed so that "\n" gets removed and the both prints on the same line. I have tried .trim()
but it's not working.
fn main () {
let mut s = String::new();
std::io::stdin().read_line(&mut s).expect("_");
s.trim();
s.push_str(",World");
println!("{}",s);
}
Output I am getting.
hello
hello
,World
Output I want.
hello
hello,World
Solved:
fn main () {
let mut s = String::new();
std::io::stdin().read_line(&mut s).expect("_");
s.pop();
s.push_str(",World");
println!("{}",s);
}