fn main() {
println!("Hello, world!");
}
Main function
Trust also takes the main function as the entry point of the executable program. The main function is the default main function entry, which has no return value and no parameters.
Keyword FN
FN is the abbreviation of function. When writing a function definition, FN is essential.
compile
main.rs The file suffix for is.rs
. Compilation requires executionrustc main.rs
。
sentence
Statement must be;
ending. Statement blocks use braces.
Printout
println!
Is a printout macro, not a function. How to distinguish macro from function? exclamatory mark,println
It is followed by an exclamation point, which means it is a macro.
implement
After windows compiles, the EXE file is generated and the command can be executed.\main.exe
. Under Linux, execute the command./main
。
reference resources
This work adoptsCC agreementReprint must indicate the author and the link of this article