Function: A code segment with specific functions. It can be divided into library functions and custom functions.
Function Definition:
Function return value type function name (formal parameter list)
{
Code segment;
Return return value;
}
Note: Each function can return only one value. Return indicates the end of a function.
Formal parameter: the virtual parameter name used for Function Definition to receive the actual value passed in function calls.
Actual parameter (real parameter): the actual value contained in the function call.
Note: function call? In use, will the parameter be copied? What is the real parameter content? Method.
Three Components of a function: function declaration, function definition, and function call.
Function Declaration: a simple description of a function, also called a function prototype.
Before the main function, the function declaration can be omitted. After the main function, the function must be affirmed before the main function.
Function declaration and definition location: the source file contains the header file and implementation file.
Function declaration is generally in the header file. The header file is XXXX. h file. The function definition is generally written in the implementation file, and the implementation file is XXXX. M file.
Array as a function parameter: When an array is used as a parameter, the format is the same as that of a common parameter, but it is not a simple data copy, but the first address of the array is passed, in this case, the parameters and real parameters share the same memory space.
Functions can be nested, but cannot be nested.
Variable: global variable, local variable.
Global variables: variables that can be called in the corresponding function space. Local variables can only be called if they have meaning within the corresponding local braces, after a local variable is called, it is automatically released by the system.