I am trying to create file using keyboard input, but the created file's name has unnecessary symbols.
use std::io;
use std::fs::File;
fn main() {
let mut filesname = String::new();
io::stdin().read_line(&mut filesname)
.ok()
.expect("cant read string");
filecreate(&filesname);
}
fn filecreate(path: &str) {
let f = File::create(path);
println!("Ok, file {} was created.", path);
}
Using this code I wrote "foo.txt"
, but my file manager shows this file as "'foo.txt'$'\n'".
I can't figure out what I have to do with the user's input.