function_pointers.c
author Markus Bröker <mbroeker@largo.dyndns.tv>
Wed, 26 May 2010 13:38:53 +0200
changeset 125 9c0fdc119939
parent 103 be3fe4a4f097
child 140 05d42a3737a4
permissions -rw-r--r--
postgresql_db: check connection status During startup, check for a successfull connection to the db committer: Markus Bröker <mbroeker@largo.homelinux.org>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24
9cdad6c45b47 function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     1
/**
77
49e0babccb23 HEADER TAGS
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 27
diff changeset
     2
 * function_pointers.c
24
9cdad6c45b47 function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     3
 */
9cdad6c45b47 function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     4
9cdad6c45b47 function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     5
#include <stdio.h>
9cdad6c45b47 function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     6
#include <stdlib.h>
9cdad6c45b47 function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     7
103
be3fe4a4f097 Function Pointer Demo simplified
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
     8
int plus (int a, int b)
24
9cdad6c45b47 function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     9
{
103
be3fe4a4f097 Function Pointer Demo simplified
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    10
    return a + b;
24
9cdad6c45b47 function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    11
}
9cdad6c45b47 function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    12
103
be3fe4a4f097 Function Pointer Demo simplified
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    13
int minus (int a, int b)
24
9cdad6c45b47 function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    14
{
103
be3fe4a4f097 Function Pointer Demo simplified
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    15
    return a - b;
24
9cdad6c45b47 function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    16
}
9cdad6c45b47 function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    17
103
be3fe4a4f097 Function Pointer Demo simplified
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    18
int func (int (*ptrFunc) (int, int), int a, int b)
24
9cdad6c45b47 function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    19
{
103
be3fe4a4f097 Function Pointer Demo simplified
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    20
    return ptrFunc (a, b);
24
9cdad6c45b47 function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    21
}
9cdad6c45b47 function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    22
27
81a574d60c15 typo in min2time format string
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 24
diff changeset
    23
int main (int argc, char **argv)
24
9cdad6c45b47 function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    24
{
103
be3fe4a4f097 Function Pointer Demo simplified
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    25
    printf ("Result: %d\n", func (&plus, 10, 20));
be3fe4a4f097 Function Pointer Demo simplified
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 77
diff changeset
    26
    printf ("Result: %d\n", func (&minus, 10, 20));
24
9cdad6c45b47 function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    27
27
81a574d60c15 typo in min2time format string
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 24
diff changeset
    28
    return EXIT_SUCCESS;
24
9cdad6c45b47 function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    29
}