- 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