author | Markus Bröker<broeker.markus@googlemail.com> |
Sun, 10 Feb 2019 13:17:01 +0100 | |
changeset 173 | 374a86886bc5 |
parent 140 | 05d42a3737a4 |
permissions | -rw-r--r-- |
24
9cdad6c45b47
function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
1 |
/** |
77 | 2 |
* function_pointers.c |
140
05d42a3737a4
Comments corrected: misspellings and other trivial things
Markus Bröker <mbroeker@volpe.spectre.org>
parents:
103
diff
changeset
|
3 |
* Copyright (C) 2009 Markus Broeker |
24
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 |
|
9cdad6c45b47
function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
6 |
#include <stdio.h> |
9cdad6c45b47
function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
7 |
#include <stdlib.h> |
9cdad6c45b47
function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
8 |
|
103
be3fe4a4f097
Function Pointer Demo simplified
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
77
diff
changeset
|
9 |
int plus (int a, int b) |
24
9cdad6c45b47
function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
10 |
{ |
103
be3fe4a4f097
Function Pointer Demo simplified
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
77
diff
changeset
|
11 |
return a + b; |
24
9cdad6c45b47
function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
12 |
} |
9cdad6c45b47
function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
13 |
|
103
be3fe4a4f097
Function Pointer Demo simplified
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
77
diff
changeset
|
14 |
int minus (int a, int b) |
24
9cdad6c45b47
function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
15 |
{ |
103
be3fe4a4f097
Function Pointer Demo simplified
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
77
diff
changeset
|
16 |
return a - b; |
24
9cdad6c45b47
function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
17 |
} |
9cdad6c45b47
function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
18 |
|
103
be3fe4a4f097
Function Pointer Demo simplified
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
77
diff
changeset
|
19 |
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
|
20 |
{ |
103
be3fe4a4f097
Function Pointer Demo simplified
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
77
diff
changeset
|
21 |
return ptrFunc (a, b); |
24
9cdad6c45b47
function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
22 |
} |
9cdad6c45b47
function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
23 |
|
27
81a574d60c15
typo in min2time format string
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
24
diff
changeset
|
24 |
int main (int argc, char **argv) |
24
9cdad6c45b47
function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
25 |
{ |
103
be3fe4a4f097
Function Pointer Demo simplified
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
77
diff
changeset
|
26 |
printf ("Result: %d\n", func (&plus, 10, 20)); |
be3fe4a4f097
Function Pointer Demo simplified
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
77
diff
changeset
|
27 |
printf ("Result: %d\n", func (&minus, 10, 20)); |
24
9cdad6c45b47
function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
28 |
|
27
81a574d60c15
typo in min2time format string
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
24
diff
changeset
|
29 |
return EXIT_SUCCESS; |
24
9cdad6c45b47
function pointer demo added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
30 |
} |