![]() |
VOOZH | about |
A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. Like any variable or constant, a pointer must be declare before storing any variable address. The general form of a pointer variable declaration is:
Syntax:
type *var_name;
Here, type is the pointers base type. It must be a valid C/C++ data type and var-name is the name of the pointer variable. The asterisk * is being used to designate a variable as a pointer. Following are the valid pointer declaration for their respective data type:
int *ip; float *fp; double *dp; char *cp;
In this article, the focus is to differentiate int* p() and int (*p)().
int* p(): Here "p" is a function that has no arguments and returns an integer pointer.
int* p() returntype function_name (arguments)
Below is the program to illustrate the use of int* p():
9
int (*p)(): Here "p" is a function pointer which can store the address of a function taking no arguments and returning an integer. *p is the function and 'p' is a pointer.
Below is the program to illustrate the use of int (*p)():
14