// tebak angka 1-100
use std::io; //prelude
fn main() {
println!("Guest the number!");
println!("Please input your guess: ");
let mut guess = String::new(); // by default, variable in rust is immutable
io::stdin()
.read_line(&mut guess) // method read_line()
.expect("Failed to read line");
println!("You guessed: {guess}");
}
output:
PS D:\rust-sc\guessing_game> cargo run
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s
Running `target\debug\guessing_game.exe`
Guest the number!
Please input your guess:
7
You guessed: 7
Tidak ada komentar:
Posting Komentar