Question: Big picture: I have a module with functions and a module with procedures and functions over those functions.

When I combine two functions (from function's module interface):

```
double f1(double alpha, double x);
double f2(double beta, double x);

```

In several ways, (one of them is adding):

```
double OP_Addition(double (*f)(double,double) , double (*g)(double,double), double param1, double param2, double x);

```

Gives no problem with the following (piece of) implementation:

```
z1 = (*f)(param1, x);
z2 = (*g)(param2, x);
y = z1 + z2;
return y;

```

But when I want to return a pointer to a "new" function, something like:

```
void *OP_PAdd( double (*f)(double,double), double param3 );

```

I can not get it to work properly, neither make the right "call". I want to have use the output "function" as input in other functions.

Answer: 
Do you mean something like this? The `decider()` function returns a pointer to another function, which is then called.

```
#include <stdio.h>
#include <stdlib.h>

typedef double(*fun)(double, double);

double add(double a, double b) {
    return a + b;
}

double sub(double a, double b) {
    return a - b;
}

double mul(double a, double b) {
    return a * b;
}

fun decider(char op) {
    switch(op) {
        case '+': return add;
        case '-': return sub;
        case '*': return mul;
    }
    exit(1);
}

int main(void)
{
    fun foo;

    foo = decider('+');
    printf("%f\n", foo(42.0, 24.0));

    foo = decider('-');
    printf("%f\n", foo(42.0, 24.0));

    foo = decider('*');
    printf("%f\n", foo(42.0, 24.0));

    return 0;
}

```

Program output:

```
66.000000
18.000000
1008.000000

```

**EDIT:** Following comments under the **@dbush answer**, this version steps back from the `typedef` as a pointer, to just a function. It gives the same output, but in `decider()` it compiles cleanly and gives the correct output, no matter whether I write `return add;` or `return &add;`

```
#include <stdio.h>
#include <stdlib.h>

typedef double(fun)(double, double);

double add(double a, double b) {
    return a + b;
}

double sub(double a, double b) {
    return a - b;
}

double mul(double a, double b) {
    return a * b;
}

fun *decider(char op) {
    switch(op) {
        case '+': return add;     // return &add;
        case '-': return sub;
        case '*': return mul;
    }
    exit(1);
}

int main(void)
{
    fun *foo;

    foo = decider('+');
    printf("%f\n", foo(42.0, 24.0));

    foo = decider('-');
    printf("%f\n", foo(42.0, 24.0));

    foo = decider('*');
    printf("%f\n", foo(42.0, 24.0));

    return 0;
}

```
in C, you can return pointer to function, but to do that, function needs to exist first, and dynamically creating functions is not something C says is possible, never mind how to do it

if your code is going to work only on one OS and one processor (and probably some other restrictions), you may be able to:

1. allocate page of memory
2. write data and machine code doing what you want, calling functions passed by pointer etc.
3. change memory protection from read/write to read/execute
4. return pointer to created function
5. don't worry that you you need 4kB per function

there probably are somewhere libraries for that, but necessarily not portable