Skip to content

Instantly share code, notes, and snippets.

@yohhoy
Last active August 29, 2015 14:09
Show Gist options
  • Save yohhoy/a3ae53709e39e8b4a34c to your computer and use it in GitHub Desktop.
Save yohhoy/a3ae53709e39e8b4a34c to your computer and use it in GitHub Desktop.
Declare function in C
#include <stdio.h>
// F is function type with 2 int args and return int.
typedef int F(int, int);
// declare function `add`, `sub`
F add, sub;
int main()
{
int r1 = add(1, 2), r2 = sub(1, 2);
printf("%d %d\n", r1, r2);
}
// define function `add`, `sub`
int add(int x, int y) { return x + y; }
int sub(int x, int y) { return x - y; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment