Reading input basics
๐ Scenario: You are creating a simple Rust program that asks the user for their name and age. This is a common task when you want to interact with people using your program.
๐ฏ Goal: Build a Rust program that reads the user's name and age from the keyboard and stores them in variables.
๐ What You'll Learn
Use the
std::io module to read inputCreate variables to store the user's name and age
Trim the input to remove extra spaces or newlines
Convert the age input from a string to a number
๐ก Why This Matters
๐ Real World
Reading input from users is essential for interactive programs like games, quizzes, or command-line tools.
๐ผ Career
Many programming jobs require handling user input safely and correctly, especially in backend or systems programming.
Progress0 / 4 steps