function_pointers.c
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--
LAST-DIGIT-BUG: INCREMENT before LF

/**
 * function_pointers.c
 * Copyright (C) 2009 Markus Broeker
 */

#include <stdio.h>
#include <stdlib.h>

int plus (int a, int b)
{
    return a + b;
}

int minus (int a, int b)
{
    return a - b;
}

int func (int (*ptrFunc) (int, int), int a, int b)
{
    return ptrFunc (a, b);
}

int main (int argc, char **argv)
{
    printf ("Result: %d\n", func (&plus, 10, 20));
    printf ("Result: %d\n", func (&minus, 10, 20));

    return EXIT_SUCCESS;
}