Pointer in C programming
Mujahida Joynab
Posted on November 4, 2024
Pointer is a variable that indicates address of another variable .
To indicate the address of a variable –
#include<stdio.h>
int main(){
int arr[5] = {1,2,3,4,5} ;
int *p = &arr[0] ; // p is initialized as the address of arr[0]
printf("%d \n", p) ;
}
Output –
6422016 //The address vary each time the program runs.
Indicating the address of a variable with pointer is called referencing.
Indicating the value of the variable with pointer is called dereferencing .
Code for dereferencing
#include<stdio.h>
int main(){
int arr[5] = {1,2,3,4,5} ;
int *p = &arr[0] ;
printf("%d \n", *p) ;
}
Output - 1
💖 💪 🙅 🚩
Mujahida Joynab
Posted on November 4, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.