int doThis(int v){ int rc=1; if(v > 0){ rc =v* doThis(v-1); } return rc; }
int main (int argc, char *argv[]) { game data; game *dataPtr = &data; data.p1.money = 1; printf("%d\n", data.p1.money); doThis (dataPtr); printf("%d\n", data.p1.money); return EXIT_SUCCESS; }
/** * Do something to every module which is registered. * @param doThis the callback. * @param registry state. */ static void forEachModule(int (*doThis)(struct DHTModule* module, struct DHTMessage* message), struct DHTMessage* message, const struct DHTModuleRegistry* registry) { struct DHTModule** modulePtr = registry->members; struct DHTModule* module = *modulePtr; while (module) { if (doThis(module, message) != 0) { return; } modulePtr++; module = *modulePtr; } }
int main(void){ int x = 3; int y = doThis(x); printf("%d\n",y); }