func-2.c - Same program - without explicit use of the address and dereferencing operators. | Lecture 1 - slide 23 : 34 Program 2 |
#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; }