What is a Pointer, Address Of(&) and Value Of(*) operator in C

Interview Questions
  • What is pointer in C.
  • What is Address Of(&) Operator and Value Of(*) Operator in C

What is pointer in C

A pointer in C programming language is a variable which is used to store the address of another variable. We can access the value of a variable either by variable identifier or by directly accessing the memory location using pointers. A pointer is a derived data type that is created from fundamental data types. We use (*) for defining pointer variables.

<data_type> *<identifier>;
For Example:
  int A = 100;
  int *ptr = &A;
Here, ptr is a pointer to a variable of type int and is initialized with address of A.


What is Address Of(&) Operator and Value Of(*) Operator in C

Address of Operator (&)
The & is a unary operator in C which returns the memory address of the passed operand. This is also known as address of operator.

Value of Operator (*)
The * is a unary operator which returns the value of object pointer by a pointer variable. It is known as value of operator. It is also used for declaring pointer variable.
For Example

  int A = 100;
  int *ptr = &A;
In the first statement, we first declare an integer variable and initialize it with value 100. In next statement, we are declaring a pointer to a variable of type int and initializing it with address of A.


Related Topics
What is NULL pointer in C.
What is size of a pointer variable
What is size of void pointer in C
What is Dangling Pointer in C.
What is Memory leak in C and how can we avoid it.
What happens when we try to access NULL pointer in .C
What is the scope of local and global variables in C.
What is difference between uninitialized(wild) pointer and null pointer
What is Wild pointer in C.
What are the advantages of using Pointers in C.