C functions in the language:
The definition of a function is a encapsulated code snippet, each function can implement different functions
define the purpose of the function: encapsulate a common feature to make it easier to call later
What happens when you define a function: Add a new feature that is commonly used
Define the format of the function:
return value type function name (formal parameter list)
{
function body;
}
Formal parameters and arguments:
Formal parameter: A parameter that is followed by a function name when defining a function, for short, a formal parameter
Actual parameters: Invoking the specific data passed into the function, referred to as an actual argument
The number of arguments must be equal to the number of formal parameters
The function body cannot define the same variables as the parameters
If the base data type is a function parameter and is purely a value pass, modifying the value of the function's internal parameter does not affect the value of the outer argument.
A function can have no formal parameter, or it can have an infinite number of arguments
return value:
C The return value in the language is very weak.
return the role of:
1. Exit Function
2. returns a specific value to the function call
3. return to re-enter
4. If a function does not have a write return value type the default is int type
5.Void represents no return value
6. Even if the return value is clear, you can return no value
Function usage time should be noted:
The name of the function is not allowed by default
The definition of a function cannot be nested
Functions cannot be defined repeatedly, but can be declared repeatedly
function as long as the declaration must be defined: the compilation will only detect the syntax is not reasonable, do not detect the function has no definition; link error, it will detect whether the function is defined
Add:
#include the role
1. Copying Files
2. If the custom file is double quotation marks, if the system comes with the <>
3.#include file is intended to copy the declaration of the printf function
Link: Combine all relevant. o Target files in the project with the C language library to build the executable file
In the C language, the header file is the declaration of the function. The definition of the H function. c file.
If you want to use a function defined in a. c file, just include the declaration file for the. c file. h
int main ()
{
printf (" This function also has a return value, its return value type is int, it returns the value is the number of characters, and a Chinese character occupies 3 bytes");
return 0;// returns to the system if the return 0 program is normal exit;
}
This article is from the "I am the way of it Growth" blog, please be sure to keep this source http://jeason.blog.51cto.com/9704473/1596423
Functions in C and supplemental descriptions of # include