2

Python has a partial function, like the example below:

func = partial(anyFunction, "some_argument")
turtle.Screen().onkey(func, "Up")

Thus, I can use arguments in a function I am passing as argument.

In C language there is something similar? I need it because in a certain function has as its parameter the pointer to another function. I need to pass an argument to this function. As in the case below:

void test(int value) {
    printf("Value: %d\n", value);
}

void test2() {
    printf("Test2!\n");
}

void makeYNQuestion(char question[], const void *yesFunction, const void* noFunction) {
    [...]
}

makeYNQuestion("my question", &test, &test2);

Need to pass some value to the test. How to solve this?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
macabeus
  • 4,156
  • 5
  • 37
  • 66

0 Answers0