
In this tutorial, we will study what are pointers in c programming, the advantage of using a pointer, the disadvantage of using pointers, operators using pointers, and a suitable example of pointers. So let’s go...
The pointers are variables that store the address of another variable. And every variable has a unique address in memory. These addresses are in hexadecimal form, so we cannot store these addresses in any normal variables, create a pointer variable to store the address of any variable. To declare which variable of pointer type, declare it with an asterisk (*) Symbol.
Syntax of its declaration: -
data_type *pointer_name;
To access the value of this variable by the address of the storage call of any variable, it is necessary to store the address of the storage call of this variable in another pointer-type variable. Because we cannot access any memory storage call without storing it in any variable.
The & (Address-of) operator points to the address of the variable. From this, we can get the address of any variable.
The * (Value-at) operator only works with pointer variables. This operator represents the value stored at a particular address.
Example:-
#include<stdio.h>
int main()
{
int rehanAge = 55;
int *ptr;
ptr = &rehanAge;
/* address of rehanAge */
printf(“Address of rehanAge: %dn”,ptr);
/* value at rehanAge */
printf(“Value of rehanAge: %d”,*ptr);
}
Output
Address of rehanAge: -1074204644
Value of rehanAge: 55
Originally posted on - Pointer in C Programming