Pointers store the address of variables or a memory location. Pointers are a symbolic representation of addresses. They enable programs to simulate call-by-reference as well as to create and manipulate dynamic data structures. Its general declaration in C/C++ has the format:
In this example “ptr” is a variable name of the pointer that holds address of an integer variable.
In this article, the focus is to differentiate between the two declarations of pointers i.e., int (*p) and int *p.
For int (*p): Here “p” is the variable name of the pointer which can point to an array of three integers.
Below is an example to illustrate the use of int (*p):
1 2 3
For int *p: Here “p” is an array of the size 3 which can store integer pointers.
Below is an example to illustrate the use of int *p:
1 2 3