Print hello world with Rust!

step 1

Create a new folder named rustDemo on the desktop (choose the folder name as you like)

Step 2

Open the newly created folder, enter cmd in the address input field  and press Enter to enter the command line window.

Step 3

Open the compiler, press Ctrl + S , and save the file to the rustDemo folder. I named the saved file hello_world.rs . The file name can be chosen arbitrarily, but the suffix must be .rs

Step 4

Back in the compiler, let's start writing specific code. Write the following code. After writing, press Ctrl + S to save.

fn fn main() {
	println!("hello world!");
}

Step 5

Go back to the previously created rustDemo folder, and then enter cmd in the address bar. Press Enter to open the command line window and enter: rustc hello_world.rs and then press Enter. After rustc is compiled, you will find that the following 2 are added to the folder. document

Step 6

Do not close the command line window, continue to enter on the second line: hello_world.exe   and press Enter, you will find hello world! It was printed

Guess you like

Origin blog.csdn.net/weixin_53989417/article/details/132630269