All pastes #834746 Raw Edit

Mine

public text v1 · immutable
#834746 ·published 2007-12-28 12:57 UTC
rendered paste body
typedef struct funktio {
  char *nimi;
  void (*ptr)();
};

funktio funktiot[] {
 {"getA", &getA},
 {"getB", &getB),
 {NULL, NULL}
}

void (*haeFunktio(const char *nimi))()
{
  int i;
  while (funktiot[i].nimi != 0) {
    if (!strcmp(funktiot[i].nimi, nimi))
      return funktiot[i].ptr;
    i++;
  }
  return NULL;
}