There is a basic code in the book that implements an example of declaring and using an array of function pointers. When compiling on Windows7 64x in DevC ++, the error is written in "void (* f [3]) (int) = (function1, function2, function3);"
[Warning] left-handed operand
Can you explain why the example does not work?
#include <stdio.h> #include <stdlib.h> void function1(int); void function2(int); void function3(int); main() { void (*f[3])(int)= (function1, function2, function3); int choice; printf("Enter a number between 0 and 2, 3 to end: "); scanf("%d", &choice); while (choice >= 0 && choice < 3) { (*f[choice])(choice); printf("Enter a number between 0 and 2, 3 to end: "); scanf("%d", &choice); } printf("You entered 3 to end\n"); system("PAUSE"); } void function1(int a) { printf("You entered %d so function1 was called\n\n", a); } void function2(int b) { printf("You entered %d so function2 was called\n\n", b); } void function3(int c) { printf("You entered %d so function3 was called\n\n", c); }