Back to slide -- Keyboard shortcut: 'u'        next -- Keyboard shortcut: 'n'          func-1.c - C program with function pointer.Lecture 1 - slide 23 : 34
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;
}