array of function pointers ..
I have program which has an array of function pointers.
Code:
#include <stdio.h>
int (* arrFunPtr[5])(void);
void f1(void);
void f2(void);
void f3(void);
void f4(void);
void f5(void);
void f1()
{
printf("Iam in f1 \n");
}
void f2()
{
printf("Iam in f2 \n");
}
void f3()
{
printf("Iam in f3 \n");
}
void f4()
{
printf("Iam in f4 \n");
}
void f5()
{
printf("Iam in f5 \n");
}
int main()
{
int choice=0;
arrFunPtr[0] = &f1; // line 43
printf("Please Enter Your Choice \n");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("zero \n");
arrFunPtr[choice-1]();
break;
default:
printf("Default \n");
break;
}
return 0;
}
When i compile it , gives me an warning as ..
ex6.c: In function `main':
ex6.c:43: warning: assignment from incompatible pointer type
When i execute it , gives me the desired result.
Iam concerned about the warming .
Can any one let me know about this.