#include <stdio.h>
typedef int (*fx)(void); // fx is pointer to function taking no parameters and returning int
int foo_1
(void) { printf("%s\n", __func__
); return 1; } int foo_2
(void) { printf("%s\n", __func__
); return 2; } int foo_three
(void) { printf("%s\n", __func__
); return 3; }
int main(void) {
fx foo[3] = { foo_1, foo_2, foo_three };
for (int k = 0; k < 3; k++) {
printf("foo[%d]() returns %d\n", k
, foo
[k
]()); }
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp0eXBlZGVmIGludCAoKmZ4KSh2b2lkKTsgLy8gZnggaXMgcG9pbnRlciB0byBmdW5jdGlvbiB0YWtpbmcgbm8gcGFyYW1ldGVycyBhbmQgcmV0dXJuaW5nIGludAoKaW50IGZvb18xKHZvaWQpIHsgcHJpbnRmKCIlc1xuIiwgX19mdW5jX18pOyByZXR1cm4gMTsgfQppbnQgZm9vXzIodm9pZCkgeyBwcmludGYoIiVzXG4iLCBfX2Z1bmNfXyk7IHJldHVybiAyOyB9CmludCBmb29fdGhyZWUodm9pZCkgeyBwcmludGYoIiVzXG4iLCBfX2Z1bmNfXyk7IHJldHVybiAzOyB9CgppbnQgbWFpbih2b2lkKSB7CiAgICBmeCBmb29bM10gPSB7IGZvb18xLCBmb29fMiwgZm9vX3RocmVlIH07CiAgICBmb3IgKGludCBrID0gMDsgayA8IDM7IGsrKykgewogICAgICAgIHByaW50ZigiZm9vWyVkXSgpIHJldHVybnMgJWRcbiIsIGssIGZvb1trXSgpKTsKICAgIH0KfQo=