DEV Community

Semenystiy Andriy
Semenystiy Andriy

Posted on • Updated on

Rust console pause

Use crate pause_console or this function:

use std::io::{stdin, stdout, Read, Write};

fn pause() {
    let mut stdout = stdout();
    stdout.write(b"\nPress Enter to continue...").unwrap();
    stdout.flush().unwrap();
    stdin().read_line(&mut String::new()).unwrap();
}
Enter fullscreen mode Exit fullscreen mode

Alt Text
It's similar to c++ system("pause")

Discussion (0)