This article takes 1. Array parameter passing and pointer parameter passing 2. Function pointer 3. The relevant knowledge of function pointer array is explained in detail!
If you think the article is good, I look forward to your one-click triple link. Your encouragement is the source of my creative motivation. Let us work together, run together, and let us meet at the top! ! !
Table of contents
1. Array parameter passing and pointer parameter passing
3. First-level pointer parameter passing
4. Secondary pointer parameter passing
1. Necessary knowledge of function pointers
1. Introduction to function pointer array
2. Use of function pointer array:
1. Array parameter passing and pointer parameter passing
1. One-dimensional array
For the parameter passing of one-dimensional array, the formal parameter part can be an array or a pointer;
like:
Note : Although the formal parameter is written in the form of an array, it is actually implemented through a pointer, but the syntax allows it to be written in the form of an array;
2. Two-dimensional array
Two-dimensional array parameter passing, the part of the formal parameter can be an array or a pointer;
3. First-level pointer parameter passing
Notice:
When customizing functions, pay attention to whether the formal parameters and actual parameter types can match;
4. Secondary pointer parameter passing
2. Function pointer
1. Necessary knowledge of function pointers
array pointer -- pointer to array
function pointer -- a pointer to a function
Let's look at this code first:
The output is:
in conclusion:
The function name represents the address of the function;
&The function name also represents the address of the first element;
Function pointer variable -- a variable that stores the address of a function
2. Use of function pointers
Demonstrate with example:
3. Array of function pointers
1. Introduction to function pointer array
An array is a storage space that stores data of the same type
For example int * arr[10]={0};
Then store the address of the function in an array, then this array is called an array of function pointers, how to define the array of function pointers?
the answer is:
parr1 parr1 is first combined with [ ] , indicating that parr1 is an array, what is the content of the array?
is a function pointer of type int (*)() ;
2. Use of function pointer array:
operation result:
end of this chapter~