Hello, World
Here is a simple "Hello World" program in Rust:
fn main() {
println!("Hello, World!");
}
Steps to Compile and Build
Save the code: Save the above code in a file named
main.rs
.Open a terminal: Navigate to the directory where
main.rs
is saved.Compile the code: Use the
rustc
compiler to compile the code. Run the following command:rustc main.rsRun the executable: After compilation, an executable file named
main
(ormain.exe
on Windows) will be created. Run it using:./main
This will output:
Hello, World!
Last modified: 01 January 2025