Answers for "rust get input on the same line as question"

0

rust get input on the same line as question

use std::io::{self, Write};

fn main() {
    let mut input = String::new();
    print!("Enter a string >> ");
    let _ = io::stdout().flush();
    io::stdin().read_line(&mut input).expect("Error reading from STDIN");
}
//use flush
Posted by: Guest on March-18-2022

Browse Popular Code Answers by Language