In C, is there a way to call a function with arguments stored in some array? I'm a C newbie, I'm not even sure if this is right but e.g.:
void f0(int a) { ... };
void f1(int a, int b) { ... };
void f2(int a, int b, int c) { ... };
int array[5][2][?] = [
[&f0, [5]],
[&f1, [-23, 5]],
[&f2, [0, 1, 2]],
[&f2, [1235, 111, 4234]],
[&f0, [22]]
];
int i;
for (i = 0; i < 5; i++) {
APPLY?(array[i][0], array[i][1])
}
PS: What kind of structure should I use when the array's items vary in length?
In Python, this would be:
def f0(a): ...
def f1(a, b): ...
def f2(a, b, c): ...
array = [
(f0, (5,)),
(f1, (-23, 5)),
(f2, (0, 1, 2)),
(f2, (1235, 111, 4234)),
(f0, (22,))
]
for f, args in array:
apply(f, args)