Last active
December 16, 2015 17:09
-
-
Save grahamking/5468331 to your computer and use it in GitHub Desktop.
Rust: Ask your name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Ask the user for their name */ | |
fn ask_name(prompt: ~str) -> ~str { | |
println(prompt); | |
return io::stdin().read_line(); | |
} | |
fn main() { | |
let name = ask_name(~"What is your name?"); | |
println(fmt!("Hello %s", name)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment