From 9ed1364e0e2fe4eb41694b471e8a0cf70ab3fb8d Mon Sep 17 00:00:00 2001 From: Ahurac Date: Tue, 9 Apr 2024 09:46:03 +0200 Subject: [PATCH] main : boucle pour lire stdin --- src/main.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e7a11a9..90085a7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,14 @@ +use std::io::Write; + fn main() { - println!("Hello, world!"); + let mut user_input = String::new(); + let mut bytes_read = 1; + + while bytes_read != 0 { + print!("$ "); + std::io::stdout().flush().unwrap(); + bytes_read = std::io::stdin() + .read_line(&mut user_input) + .expect("error reading user input"); + } }