DEV Community

Discussion on: Types in C: The void (*(*[])())()

Collapse
 
pentacular profile image
pentacular • Edited
// The correct answer is that this is an opportunity to learn typedef. :)

#include <stdio.h>

void apple() { printf("apple\n"); }

typedef void op();

// And that a function expression evaluates to a pointer to that function.

op *iapple() { return apple; }

typedef op *iop();

// So we don't need those &s.

iop *ops[] = { iapple };

// Hurrah.

int main() {
  ops[0]()();
}