diff --git a/Projects/guessing_game/Cargo.toml b/Projects/guessing_game/Cargo.toml new file mode 100644 index 0000000..405609f --- /dev/null +++ b/Projects/guessing_game/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "guessing_game" +version = "0.1.0" +edition = "2021" +authors = ["HaQadosch Berraka "] +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/Projects/guessing_game/src/main.rs b/Projects/guessing_game/src/main.rs new file mode 100644 index 0000000..f26eed5 --- /dev/null +++ b/Projects/guessing_game/src/main.rs @@ -0,0 +1,14 @@ +use std::io; + +fn main() { + println!("Guess the number:"); + println!("Please enter your guess"); + + let mut guess = String::new(); // Creates a mutable variable as empty string. + + io::stdin() + .read_line(&mut guess) + .expect("Failed to read line"); + + println!("You guessed: {guess}"); +} diff --git a/README.org b/README.org index 32fc27b..587d4f4 100644 --- a/README.org +++ b/README.org @@ -31,7 +31,7 @@ To update *rustup* and please do regularly #+begin_src shell :results output rustup update #+end_src - +( #+RESULTS: update rustup : stable-x86_64-unknown-linux-gnu unchanged - rustc 1.76.0 (07dca489a 2024-02-04) *** Documentation @@ -183,3 +183,6 @@ To build a cargo with an optimised build, run #+end_example The build results are in the folder =target/release/= now. + +**** +* Programming a guessing game