A Pointer is a special variable that stores the address of another variable rather than storing the values. Thus, with the help of pointers, any variable can be accessed by its address.
Accessing a variable by its address is faster than accessing it by its name as the compiler is to first get the address of that variable and in the second cycle need to access that address.
Pointers are used to access memory and manipulate the address.
What does address of a memory location mean?
Whenever a variable is defined in C language, memory is allocated to that variable in which the value will be stored. The address can be checked with the ampersand(&) symbol.
If var is the name of the variable, its address can be fetched with &var.
Example:
#include <stdio.h>
int main ()
{
int var = 5;
printf ("\n The memory address of the variable var is: %x\n", &var);
return 0;
}
Output:
The address of the variable var is: 15e490ac
Concept of pointers:
Whenever a variable is defined in a program, a memory address is allocated which holds the value. This address can be accessed and manipulated by pointers.

Since the memory address is also a number, they can be placed in some other variable. The variables that hold the memory address are known as pointers.
Hence, a pointer is nothing but a variable which holds the address of some other variable and even this variable will have its own address.

Advantages of Pointer:
- Pointer helps in passing data as a pass-by-reference to function.
- It is efficient in handling arrays and structure.
- This allows the C program to support dynamic memory management.
In the next section, we will be covering the declaration, initializing, and using the pointer variable in C.
Relevant Posts:
- Pointer declaration, initialization and dereferencing
- Double Pointer
- Operation on Pointers
- Pointer to an array
- Array of pointers
- String and pointer
- Pointer to structure
- Function pointer
- Passing pointer to function
- Dangling pointer and memory leak
- Null and Void pointers
Categories: C Language
Leave a Reply