Function pointer is a kind of C pointer.
Ask "What's the difference between a function pointer and a pointer?" Explain that LZ is still careless about pointers. Modify your question:
"What is the difference between a function pointer and an integer pointer?"
In this case, I will tell you:
1. Both are pointers.
2. The function pointer stores the first address of the function, and the integer pointer stores the address of the integer variable;
3. Pointer itself is a reference type. Therefore, when using, all references should be dereferenced. The dereference of function pointers is different from integer pointers. Integer pointers can be dereferenced in two ways:
For example, the integer pointer pi:
int I = 0;
Int * pi = &
Method of dereference 1:* pi
Method 2: pi[0]
For function pointer pf:
int f(int);
int(* pf)(int)= f;
De-quoting method: PF (8);
Integer pointer dereference method 2: pi[0] is more like an array. It is also more like a method of dereferencing function pointers, because:
Array names and function names are essentially addresses. The essence of a pointer is also an address.
4。 As can be seen from the above example, the assignment forms are different.
Function pointer pf = f;; (No need &. In fact, it is the same)
Integer pointer pi = &;; Me;
The reason is that the essence of array names and function names is the address, while the essence of integer variables (when left or right values are allowed) is the value in the address.
5. For function pointers, generally, you can't do incremental operations, such as: pf++ 99.9999% will crash.
If you want to access the function array, you need to use the function pointer array.