summaryrefslogtreecommitdiff
path: root/funcptr_example.c
blob: bc904a9ecf990e45103143230a391cb821aad761 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdio.h>

int func_one()
{
  printf("This is function one\n");
  return 1;
}

int func_two()
{
  printf("this is function two\n");
  return 2;
}

int main(int argc, const char *argv[])
{
  int value;
  int (*function_ptr) ();
  function_ptr = func_one;
  printf("function_ptr is %p\n", function_ptr);
  value = function_ptr();
  printf("value returned was %d\n", value);

  function_ptr = func_two;
  printf("function_ptr is %p\n", function_ptr);
  value = function_ptr();
  printf("value returned was %d\n", value);
  return 0;
}