Before you know what a function call is, what is a function first? A function is a self-contained unit of program code that is used to complete a particular task. Why use a function? 1) The use of functions can eliminate the duplication of code writing. 2) Facilitate the reading, modification and improvement of the program.
What is a function call? Function call is a much more concept used in program design, for example, there is a main function, function is required to calculate a+b, we can go ahead to define a custom function for the process, the function is to calculate the a+b, and then let main to call. But the invocation is principled, and the main function can call all the non-main functions, and the non-main functions can call each other, but the main function cannot be called.
In the actual project, a program is usually composed of many sub-program modules, a module to achieve a specific function, in C language, the module is represented by a function. A C program is generally composed of a main function and several other functions. The main function can call other functions, and other functions can call each other, but other functions cannot call the main function.
The general form of a function call is the function name (the argument list), the function name is the name of the function that needs to be called, and the argument list is the parameter list that calls the function to be passed to the called function according to the actual requirement, no need to pass parameters, only the parentheses are allowed, and the arguments are separated by commas.
A small example:
#include <stdio.h>
int main ()
{
int a,b,sum;
a=10;
b=24;
Sum=add (A, b); function Call, the following add function is called
printf ("sum=%d\n", sum);
}
int Add (int x,int y)//define a function
{
int z;
Z=x+y;
return (z);
}
C language-function call