Computer >> Computer tutorials >  >> Programming >> C programming

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.