What is a function
Any C language program is composed of one or more program segments (small programs). Each program segment has its own functionality, which we generally call "functions". So, you can say that the C language program is composed of functions.
Definition of two functions
1 Defining the purpose of a function
Save a common feature for later use.
2 steps to define a function
Function Name: What is the name of the functions?
Function Body: What does the function do and what code it contains.
3 format
Fixed format
Name of function
{
function contents
}
Return
1 Effects:
(1) Exit function
(2) returns a body value.
The function uses the note point:
(1) If the return value type is not explicitly declared, the default is the int type.
(2) Function name cannot be duplicated.
(3) Two functions call most of each other into the dead loop until the memory is fully occupied
Steps to define a function:
1 clear function, define a function name.
2 function body.
As follows:
void Huangcan ()
{
printf ("Huangcan");
}
If there is a declaration of a function, it cannot be called.
Error Example:
int main ()
{
Huangcan ();
}
void Huangcan ()
{
printf ("Huangcan");
}
Because the compiler defaults to compiling from the top down
No correlation function declaration was obtained before calling function
C Language Function Learning notes