C中函数名前的*是什么意思?

What does * in front of function name mean in C?

在函数名前加一个*到底是什么意思?

还有这两个代码有什么不同?

int *modify_array(int *array, int size);

int (*modify_array)(int *array, int size);
// declares a function which returns an int (usually 4 bytes)
int modify_array_1(int *array, int size);

// declares a function which returns an pointer (usually 8 bytes)
// that pointer is the memory address of a 4-byte int
int *modify_array_2(int *array, int size);

// declares a variable of type pointer (usually 8 bytes) which points to a function
// the function has the signature int SOMETHING(int *array, int size)
int (*modify_array_3)(int *array, int size);
// now, because modify_array_1 has that signature, you can run this:
modify_array_3 = modify_array_1;

第一行,modify_array是一个函数,return是一个指向int的指针; 但是您的第二行是指向函数的指针,因此 modify_array 是指向 return 和 int 并接受两个参数 arraysize 的函数的指针。

int *modify_array(int *array, int size);
int (*modify_array)(int *array, int size);

第一个:modify_array 是一个接受两个参数的函数returns一个指向int的指针.
第二个:modify array 是一个指向接受两个参数的函数returns 一个 int.

示例,名称已更改

#include <stdio.h>
int *fx(int *, int); // function prototype
int (*fp)(int *, int); // variable declaration
int *fx(int *a, int n) { // function definition
    return a+n; // address of a[n]
}
int fx2(int *a, int n) { // function definition, prototype, and declaration
    return a[n];
}
int main(void) {
    int ar[] = { 0, 42, 0, 0 };
    fp = fx2; // make the pointer point to a function of the right kind
    printf("%p %d\n", fx(ar, 1), fp(ar, 1));
    return 0;
}

通过指针调用函数的注意事项fp:可以解引用指针,也可以直接使用指针

#include <math.h>
double (*fx)(double) = sin;
sin(3.1416/4) == (*fx)(3.1416/4) == fx(3.1416/4);