What does “dereferencing” a pointer mean in C/C++?


Dereferencing is used to access or manipulate data contained in memory location pointed to by a pointer. *(asterisk) is used with pointer variable when dereferencing the pointer variable, it refers to variable being pointed, so this is called dereferencing of pointers.

int main() {
   int a = 7, b ;
   int *p; // Un-initialized Pointer
   p = &a; // Stores address of a in ptr
   b = *p; // Put Value at ptr in b
}

Here, address in p is basically address of a variable.

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 07-Nov-2023

20K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements