In this article Pointers in C we give the information about pointer is a special derived data type that holds the address of another variable.
Pointers in C Programming
A pointer in the C programming language is a variable used to store the address of another variable. Instead of holding an actual value, a pointer holds the memory location of that value. In simple terms, a pointer “points” to the location where the data is stored.
Definition of Pointer
- A pointer is a special variable that stores the address of another variable.
- It is a derived data type in C, meaning it is created from basic data types.
- Pointers can be of different types such as int, char, float, double, array, and function.
- The asterisk symbol (*) is used to declare a pointer variable.
- The size of a pointer depends on the system architecture. For example:
- In a 32-bit system → pointer size = 4 bytes
- In a 64-bit system → pointer size = 8 bytes
Example:
int *ptr = &n;
Here, ptr is an integer pointer that stores the address of variable n.
Through this pointer, both the value and address of n can be accessed.
Declaring a Pointer
Just like other variables, pointers also need to be declared before use.
Syntax:
data_type *pointer_name;
Example:
int *marks;
float *average;
char *grade;
Here, marks, average, and grade are pointers of different data types.
The asterisk * indicates that these variables are pointers.
Types of Pointers in C:

1 NULL Pointer
A NULL pointer is a pointer that does not point to any valid memory location.
It is initialized with a special constant NULL.
Example:
Using an uninitialized pointer can produce garbage values, so initializing with NULL is a good practice.
2 Void Pointer
A void pointer (also called a generic pointer) can hold the address of any data type.
However, it must be typecast before dereferencing.
Example:
void *ptr;
int a = 10;
ptr = &a;
3. Wild Pointer
A wild pointer is declared but not initialized with any address.
It points to random or unknown memory, which may cause program crashes.
Example:
int *ptr; // Wild pointer
4. Dangling Pointer
A dangling pointer points to a memory location that has been freed or deallocated.
Accessing such memory leads to undefined behavior.
Example:
int *ptr = (int*)malloc(sizeof(int));
free(ptr); // ptr becomes a dangling pointer
Uses of Pointers in C
Pointers play a vital role in advanced programming and memory management.
- Used in dynamic memory allocation and deallocation (malloc, calloc, free).
- Essential in data structures like linked lists, trees, and graphs.
- Used in system-level programming for accessing hardware addresses.
- Allow functions to return multiple values.
- Useful for passing variables by reference (Call by Reference).
- Used in file handling and string manipulation.
- Helpful for accessing array elements efficiently.
Advantages of Pointers
- Enables dynamic memory allocation.
- Supports array, function, and structure
- Reduces program code size.
- Allows direct access to memory addresses.
- Increases program efficiency and reduces execution time.
- Essential for Call by Reference function calls.
Disadvantages of Pointers
- Improper use may lead to memory leaks and crashes.
- If not initialized, a pointer may contain garbage values.
- Pointers make the program harder to debug.
- Wild and dangling pointers can cause serious runtime errors.
Example: Pointer in C Program
#include <stdio.h>
int main()
{
int n = 100;
int *ptr;
ptr = &n;
printf(“Value of n = %d\n”, n);
printf(“Address of n = %p\n”, ptr);
return 0;
}
Output:
Value of n = 100
Address of n = 0x7ffee6a3b8ac // (example memory address)
Conclusion
Pointers are one of the most powerful features of the C language.
They provide direct access to memory, help manage dynamic data structures, and improve program efficiency.
However, they must be used carefully to avoid errors like memory corruption and leaks.
Some More:
POP- Introduction to Programming Using ‘C’
OOP – Object Oriented Programming
DBMS – Database Management System
RDBMS – Relational Database Management System
Join Now: Data Warehousing and Data Mining