From c0c3dc2c9f74679b9ede1d90c9351a985976bd32 Mon Sep 17 00:00:00 2001 From: Aditya Gupta Date: Sun, 18 Jan 2026 20:12:59 +0530 Subject: [PATCH] feat: Taking input --- Cargo.lock | 7 +++++++ src/main.rs | 13 ++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..65b6b8d --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "guessing-game" +version = "0.1.0" diff --git a/src/main.rs b/src/main.rs index e7a11a9..d0f3161 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,14 @@ +use std::io; + fn main() { - println!("Hello, world!"); + println!("===================== Guessing Game =====================\n"); + println!("Input your guess"); + + let mut guess = String::new(); + + io::stdin() + .read_line(&mut guess) + .expect("Failed to read line"); + + println!("You guessed: {}", guess); }