Skip to content

Instantly share code, notes, and snippets.

@Maksim-Zhuravlev
Created October 4, 2017 16:25
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/07619ce5030726c2a540a4aaa012bbe2 to your computer and use it in GitHub Desktop.
Save Maksim-Zhuravlev/07619ce5030726c2a540a4aaa012bbe2 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <stdio.h>
#include <memory.h>
int f1 (int x, int y) {
return x + y;
}
int f2 (int x, int y) {
return x - y;
}
typedef int (*binaryOp)(int, int);
void main() {
binaryOp doWork = NULL;
char c;
printf("Please enter 1 or 2");
scanf("%c", &c);
if (c == '1') {
doWork = f1;
} else {
doWork = f2;
}
printf("\nResult = %d", doWork(5, 5));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment