I am writing a program in C which uses an array of function pointers. If I do not include an argument I am able to call the functions with my code without an issue.
int (*functionsArray[2][3])() = {
{functionOne,functionTwo,functionThree},
{functionFour,functionFive,functionSix}
};
However when I try and pass the argument int x:
int (*functionsArray[2][3])(int x) = {
{functionOne,functionTwo,functionThree},
{functionFour,functionFive,functionSix}
};
I get an error:
invalid conversion from 'int (*)()' to 'int (*)(int)'
Also none of these functions return an int, shouldn't I be able to declare them as void?
void(*functionsArray[2][3])(int x) = {
{functionOne,functionTwo,functionThree},
{functionFour,functionFive,functionSix}
};
Trying this results in an error:
error: invalid conversion from 'int (*)()' to 'void (*)(int)'
Thanks.
functionOneand show us at which line you get the error.functionOne,functionTwo, ... should have all exactly the same prototype. The prototype should be same as the prototype you use for the array.