function_pointers.c
changeset 103 be3fe4a4f097
parent 77 49e0babccb23
child 140 05d42a3737a4
--- a/function_pointers.c
+++ b/function_pointers.c
@@ -1,40 +1,29 @@
 /**
  * function_pointers.c
- * Copyright (C) 2008 Markus Broeker
  */
 
 #include <stdio.h>
 #include <stdlib.h>
 
-typedef struct T {
-    int a;
-    int b;
-} T;
-
-int plus (T t)
+int plus (int a, int b)
 {
-    return t.a + t.b;
+    return a + b;
 }
 
-int minus (T t)
+int minus (int a, int b)
 {
-    return t.a - t.b;
+    return a - b;
 }
 
-int func (T t, int (*ptrFunc) (T))
+int func (int (*ptrFunc) (int, int), int a, int b)
 {
-    return ptrFunc (t);
+    return ptrFunc (a, b);
 }
 
 int main (int argc, char **argv)
 {
-    T t = {
-        .a = 20,
-        .b = 10
-    };
-
-    printf ("Result: %d\n", func (t, &plus));
-    printf ("Result: %d\n", func (t, &minus));
+    printf ("Result: %d\n", func (&plus, 10, 20));
+    printf ("Result: %d\n", func (&minus, 10, 20));
 
     return EXIT_SUCCESS;
 }