summaryrefslogtreecommitdiff
path: root/function_pointers.c
diff options
context:
space:
mode:
Diffstat (limited to 'function_pointers.c')
-rw-r--r--function_pointers.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/function_pointers.c b/function_pointers.c
new file mode 100644
index 0000000..e2944dc
--- /dev/null
+++ b/function_pointers.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+void print_sum(int (*name)(int), int b) {
+ int a = name(b);
+ printf("The sum is: %d\n", a + b);
+}
+int subtract_one(int a)
+{
+ return a - 1;
+}
+int main(void)
+{
+ print_sum(&subtract_one, 7);
+ return 0;
+}