C/C++ language has a feature which allows function pointer to be declared as a pointer variable.
Syntax of a function pointer is as follows:
<return type> (*<pointer name>)(<arguments>); or typedef <return type> (*<pointer name>)(<arguments>);Here is an example of addition using function pointer.
int add(int a, int b) { return (a + b); } typedef int (add_proc)(int a, int b); int main(int argc, char *argv[]) { add_proc add_ptr; int a = 1, b = 2, c; add_ptr = add; c = add_ptr(a, b); }
About our authors: Team EQA
You have viewed 1 page out of 252. Your C learning is 0.00% complete. Login to check your learning progress.