Back to notes -- Keyboard shortcut: 'u'        next -- Keyboard shortcut: 'n'  Slide program -- Keyboard shortcut: 't'    C program with function pointer.Lecture 1 - slide 18 : 29
Program 1
#include <stdio.h>

void (*f)(char *, int);

void fun1(char *s, int i){
  printf("fun1: %s, %d\n", s, i);
}

void fun2(char *s, int i){
  printf("fun2: %s, %d\n", s, i);
}

int main(void) {
  int cond;

  printf("Enter condition (0, 1): ");
  scanf(" %d", &cond);

  if (cond)
     f = &fun1;
  else
     f = &fun2;

  (*f)("AP", 8);
  
  return 0;
}