Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <stdlib.h>
#include <stdio.h>
int firstMethod(int x) {
return x;
}
void main() {
struct Method {
char *description;
int (*doAction)(int);
};
const struct Method methods[] = {
{.description = "Descr 1", .doAction = firstMethod},
{.description = "Descr 2", .doAction = firstMethod},
};
const size_t methodsCount = sizeof(methods) / sizeof(struct Method);
for (int i = 0; i < methodsCount; i++) {
printf("%d. %s\n", i + 1, methods[i].description);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment