Skip to content

Instantly share code, notes, and snippets.

@Maksim-Zhuravlev
Created October 10, 2017 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Maksim-Zhuravlev/47e5965611598d87c44774826b4533fd to your computer and use it in GitHub Desktop.
Save Maksim-Zhuravlev/47e5965611598d87c44774826b4533fd to your computer and use it in GitHub Desktop.
#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