Last active
August 29, 2015 14:09
-
-
Save yohhoy/a3ae53709e39e8b4a34c to your computer and use it in GitHub Desktop.
Declare function in C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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