Program to read a string from the user
Rust Programming Language
Problem
In this program, we will read a string from the user using the read_lin() function and print the input string.
Input
// Rust program to read a string// from the userfn main(){let mut Str = String::new();println!("Enter String: ");std::io::stdin().read_line(&mut Str);println!("String is: {}", Str);}{codeBox}
Output
Enter String:Hello WorldString is: Hello World{codeBox}
Explanation
Here, we created a string variable Str. Then we read the string from the user using the read_line() function and printed the input string.