Pointers
Pointer:
Pointer is a variable that stores the address/reference of another variable.
Declaration of a pointer variable:
Syntax:
data-type *ptr_variable_name;
Example:
int *p;
Here p is declared as a pointer variable.
Initialization of a pointer variable:
Syntax:
*ptr_variable_name = &other_variable_name;;
Example:
int a=10;
int *p;
*p = &a;
Here the address of variable "a" is stored in pointer variable "p". And we can access the value at that address which is in fact the value of the variable "a" by placing "*" before the variable "p". i.e. "*p".
Drafted on 🌏 by,
Jal
☮
peace
Comments
Post a Comment