Advanced Pointers

📘 C 👁 36 views 📅 Dec 22, 2025
⏱ Estimated reading time: 2 min

Advanced pointers deal with complex pointer usage such as pointers to pointers, function pointers, arrays of pointers, and dynamic memory handling.


Pointer to Pointer

A pointer to pointer stores the address of another pointer.

Declaration

int **pp;

Example

int a = 10; int *p = &a; int **pp = &p;

Accessing Value

printf("%d", **pp);

Pointer and Array Revisited

  • Array name acts as a pointer to first element

  • Pointer arithmetic can access array elements

int a[3] = {10, 20, 30}; int *p = a; printf("%d", *(p + 1));

Array of Pointers

An array where each element is a pointer.

int *arr[3];

Example

int a = 1, b = 2, c = 3; int *arr[3] = {&a, &b, &c};

Pointer to an Array

A pointer that points to an entire array.

int (*p)[3];

Function Pointers

A function pointer stores the address of a function.

Declaration

return_type (*ptr)(parameter_types);

Example

int add(int a, int b) { return a + b; } int (*fp)(int, int) = add;

Function Call Using Pointer

fp(10, 20);

Void Pointers

A void pointer can store the address of any data type.

void *p;

Type casting is required before dereferencing.


Dynamic Memory and Pointers

Pointers are used to manage memory dynamically.

int *p = (int *)malloc(5 * sizeof(int));

Dangling Pointer

A pointer pointing to deallocated memory.

free(p); p = NULL;

Const Pointers

Pointer to Constant

const int *p;

Constant Pointer

int *const p = &a;

Advantages of Advanced Pointers

  • Efficient memory management

  • Supports complex data structures

  • Enables callback functions

  • Essential for system-level programming


Summary

  • Pointer to pointer stores address of another pointer

  • Function pointers store function addresses

  • Arrays and pointers are closely related

  • Proper pointer handling avoids errors


🔒 Some advanced sections are available for Registered Members
Register Now

Share this Post


← Back to Tutorials

Popular Competitive Exam Quizzes