C Programming

A pointer can also be declared as pointing to a function. The declaration of such a pointer is done by,

	int  (*func_pointer)();

The parentheses around *func_pointer are necessary, else the compiler will treat the declaration as a declaration of a function. To assign the address of a function to the pointer, the statement,

	func_pointer = lookup;

where lookup is the function name, is sufficient. In the case where no arguments are passed to lookup, the call is


The parentheses are needed to avoid an error. If the function lookup returned a value, the function call then becomes,

	i = (*func_pointer)();

If the function accepted arguments, the call then becomes,

	i = (*func_pointer)( argument1, argument2, argumentn);

ęCopyright B Brown. 1984-1999. All rights reserved.