Quote:
Originally Posted by sowmi
int aaa(int x);
void bbb(int x,int y, int z);
void ccc(void);
void ddd(char *x,char *y,char *z);
void eee(UINT8 x);
These functions will need different function pointers.
will need a function pointer:
You assign the address of the functtion to the pointer:
and then you can call the function using the pointer:
But you need a diffrerent function pointer for:
-
void bbb(int x,int y, int z);
-
-
void (*fp1)(int, int, int);
-
-
fp1 = bbb;
-
-
fp1(10,20,30);
-
Your example is not a case where you use function pointers. Function pointers are used where you have many functions with the same arguments and the same return type. Then you can choose which function to call by putting its address in a function pointer. The pointer can be passed to another function so that the other function can call different functions. This is commonly done with sorts where you pass the address of the compare function to the sort so you can sort in different sequences.