Question: How can I create a "function pointer" (and (for example) the function has parameters) in C?

Answer: 
<http://www.newty.de/fpt/index.html>

```
typedef int (*MathFunc)(int, int);

int Add (int a, int b) {
    printf ("Add %d %d\n", a, b);
    return a + b; }

int Subtract (int a, int b) {
    printf ("Subtract %d %d\n", a, b);
    return a - b; }

int Perform (int a, int b, MathFunc f) {
    return f (a, b); }

int main() {
    printf ("(10 + 2) - 6 = %d\n",
            Perform (Perform(10, 2, Add), 6, Subtract));
    return 0; }

```
First declare a function pointer:

```
typedef int (*Pfunct)(int x, int y);

```

Almost the same as a function prototype.  

But now all you've created is a type of function pointer (with `typedef`).  

So now you create a function pointer of that type:

```
Pfunct myFunction;
Pfunct myFunction2;

```

Now assign function addresses to those, and you can use them like they're functions:

```
int add(int a, int b){
    return a + b;
}

int subtract(int a, int b){
    return a - b;
}

. . .

myFunction = add;
myFunction2 = subtract;

. . .

int a = 4;
int b = 6;

printf("%d\n", myFunction(a, myFunction2(b, a)));

```

Function pointers are great fun.