Why does this read input before printing?

前端 未结 3 1836
日久生厌
日久生厌 2020-11-27 08:34

I\'m having some problems with some basic I/O stuff. Specifically, the text \"Please enter your name\" is written to the output after I type in my name and

3条回答
  •  孤街浪徒
    2020-11-27 09:10

    use std::io::{self, Write};
    
    fn main() {
        print!("Please enter your name: ");
        let _ = io::stdout().flush();
        // your io code
    }
    

提交回复
热议问题