Skip to content

Instantly share code, notes, and snippets.

@grahamking
Last active December 16, 2015 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save grahamking/5468331 to your computer and use it in GitHub Desktop.
Save grahamking/5468331 to your computer and use it in GitHub Desktop.
Rust: Ask your name
/* 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