FIRST PROGRAM

 FIRST PROGRAM

  • Create a folder in your local machine to store your rust codes.
  • Create a notepad and save it with the extension .rs
  • e.g filename.rs
  • Open it using VS Code.
  • Install the extension rust-analyser C/C++ and clippy.
  • Write your first code:
    fn main(){
        println!("Hello Nobody!")
    }
  • The above piece of code contains a main function with print statement that prints Hello Nobody! The function with the name main is the first function to be executed when the code runs.
  • After writing your code, go to the terminal in VS Code and type the following command to compile the rust code:
    rustc filename.rs
    • Followed by below command to run the compiled file:
      ./filename.exe
    • If the code is successfully executed, you will get the following response in your terminal:
      Hello Nobody!

    Comments