Update index.md (#27467)

Added note that main function is only called once.
pull/29704/head
matthewoelke 2018-12-18 12:03:49 -06:00 committed by Christopher McCormack
parent 6978178d4f
commit 2037263dba
1 changed files with 1 additions and 1 deletions

View File

@ -45,7 +45,7 @@ int main(void)
{ {
} }
``` ```
This code declares the main function. The main function is special- it will always get called and is always the 'main' part of your program. If this isn't in your program, your program can't run and won't compile. This code declares the main function. The main function is special- it will always get called exactly one time and is always the 'main' part of your program. If this isn't in your program, your program can't run and won't compile.
Starting the function declaration with `int` means that this function will give an `int` or integer value when it compiles the code- it's this function's output. `int` is the 'integer' data type, and integers are whole numbers like -3, 0, or 18. So we know that this code will run, and when it's done, it will give us back an integer. By convention, the integer has a `garbage value`. Starting the function declaration with `int` means that this function will give an `int` or integer value when it compiles the code- it's this function's output. `int` is the 'integer' data type, and integers are whole numbers like -3, 0, or 18. So we know that this code will run, and when it's done, it will give us back an integer. By convention, the integer has a `garbage value`.