If you're diving into C programming and haven’t come across pointers yet, buckle up. Pointers are one of the most fascinating (and sometimes intimidating) concepts in C. But once you get the hang of them, they open up a world of possibilities. From dynamic memory allocation to building complex data structures, pointers are the secret sauce behind many C-powered applications.

In this guide, we’ll walk you through the basics of pointers, how to use them, their syntax, examples, and common pitfalls all explained in simple terms.
Check out the C Programming Course at Uncodemy for hands-on learning.
In simple words, a pointer is a variable that stores the address of another variable. Rather than storing a value directly (like int a = 5;), a pointer holds where that value is located in memory.
Why Use Pointers?
Copy Code
int *ptr;
This declares a pointer to an integer.
To assign the address of a variable to the pointer:
int a = 10;
int *ptr = &a; // & gives the address of 'a'
To access the value stored at the pointer:
printf("%d", *ptr); // prints 10Copy Code
#include <stdio.h>
int main() {
int num = 42;
int *ptr = #
printf("Value of num: %d\n", num);
printf("Address of num: %p\n", &num);
printf("Pointer ptr stores address: %p\n", ptr);
printf("Value at the address stored in ptr: %d\n", *ptr);
return 0;
}Output:
Value of num: 42
Address of num: 0x7ffde3c9e6bc
Pointer ptr stores address: 0x7ffde3c9e6bc
Value at the address stored in ptr: 42
1. Null Pointer
int *ptr = NULL;
Used to initialize a pointer when it doesn't point to any memory location.
2. Dangling Pointer
A pointer pointing to a memory location that has been deallocated or released.
3. Void Pointer
void *ptr;
Can point to any data type but must be typecast before dereferencing.
4. Wild Pointer
Uninitialized pointer. It can point anywhere often leads to crashes.
int *ptr; // wild pointer
Arrays and pointers in C are closely related.
Copy Code
int arr[] = {1, 2, 3};
int *ptr = arr;
Now ptr points to the first element of the array.
printf("%d\n", *(ptr + 1)); // Output: 2Yes, a pointer can also point to another pointer.
Copy Code
int val = 5;
int *ptr = &val;
int **pptr = &ptr;
printf("%d\n", **pptr); // Output: 5Functions also have addresses. We can store them in pointers.
Copy Code
void greet() {
printf("Hello from function pointer!\n");
}
int main() {
void (*funcPtr)() = greet;
funcPtr();
return 0;
}Pass by Reference
Using pointers, we can pass addresses of variables to functions and modify them.
Copy Code
void update(int *x) {
*x = *x + 10;
}
int main() {
int num = 5;
update(&num);
printf("Updated value: %d\n", num); // Output: 15
return 0;
}You can allocate memory during runtime using malloc, calloc, realloc, and release it with free().
Copy Code
int *ptr = malloc(sizeof(int));
*ptr = 25;
printf("%d", *ptr);
free(ptr);Q1. Why are pointers important in C?
Because they allow low-level memory access and give programmers control over memory operations.
Q2. Can a pointer point to another pointer?
Yes. This is called a pointer to a pointer.
Q3. What is a NULL pointer?
A pointer that doesn’t point to any valid memory address.
Q4. What is pointer arithmetic?
It involves moving the pointer around using operations like increment, decrement, etc.
Q5. Are pointers used in other languages?
Not directly. Most high-level languages abstract away pointers, but they are heavily used in C and C++.
Pointers in C might take some getting used to, but once you do, you’ll wonder how you ever lived without them. They give you the power to manipulate memory directly, making your programs more efficient and flexible.
Whether you’re working with arrays, functions, or dynamic memory, mastering pointers will set a strong foundation for systems-level programming.
Looking for real-world projects and in-depth explanations of pointers?
Start your C programming journey with Uncodemy’s expert-led tutorials today!
Personalized learning paths with interactive materials and progress tracking for optimal learning experience.
Explore LMSCreate professional, ATS-optimized resumes tailored for tech roles with intelligent suggestions.
Build ResumeDetailed analysis of how your resume performs in Applicant Tracking Systems with actionable insights.
Check ResumeAI analyzes your code for efficiency, best practices, and bugs with instant feedback.
Try Code ReviewPractice coding in 20+ languages with our cloud-based compiler that works on any device.
Start Coding
TRENDING
BESTSELLER
BESTSELLER
TRENDING
HOT
BESTSELLER
HOT
BESTSELLER
BESTSELLER
HOT
POPULAR