সি প্রোগ্রামিং ভাষায়, পয়েন্টার থেকে পয়েন্টার বা ডাবল পয়েন্টার হল একটি পরিবর্তনশীল যা অন্য পয়েন্টারের ঠিকানা ধারণ করে।
ঘোষণা
পয়েন্টার থেকে পয়েন্টার -
-এর ঘোষণা নীচে দেওয়া হলdatatype ** pointer_name;
উদাহরণস্বরূপ, int **p;
এখানে, p একটি পয়েন্টার থেকে পয়েন্টার।
শুরু করা
আরম্ভ করার জন্য '&' ব্যবহার করা হয়।
উদাহরণস্বরূপ,
int a = 10; int *p; int **q; p = &a;
অ্যাক্সেস করা হচ্ছে
ইনডাইরেকশন অপারেটর (*) অ্যাক্সেস করার জন্য ব্যবহৃত হয়
নমুনা প্রোগ্রাম
ডবল পয়েন্টার -
-এর জন্য C প্রোগ্রাম নিচে দেওয়া হল#include<stdio.h>
main ( ){
int a = 10;
int *p;
int **q;
p = &a;
q = &p;
printf("a =%d ",a);
printf(" a value through pointer = %d", *p);
printf(" a value through pointer to pointer = %d", **q);
} আউটপুট
যখন উপরের প্রোগ্রামটি কার্যকর করা হয়, তখন এটি নিম্নলিখিত ফলাফল তৈরি করে -
a=10 a value through pointer = 10 a value through pointer to pointer = 10
উদাহরণ
এখন, আরেকটি সি প্রোগ্রাম বিবেচনা করুন যা পয়েন্টার থেকে পয়েন্টারের মধ্যে সম্পর্ক দেখায়।
#include<stdio.h>
void main(){
//Declaring variables and pointers//
int a=10;
int *p;
p=&a;
int **q;
q=&p;
//Printing required O/p//
printf("Value of a is %d\n",a);//10//
printf("Address location of a is %d\n",p);//address of a//
printf("Value of p which is address location of a is %d\n",*p);//10//
printf("Address location of p is %d\n",q);//address of p//
printf("Value at address location q(which is address location of p) is %d\n",*q);//address of a//
printf("Value at address location p(which is address location of a) is %d\n",**q);//10//
} আউটপুট
যখন উপরের প্রোগ্রামটি কার্যকর করা হয়, তখন এটি নিম্নলিখিত ফলাফল তৈরি করে -
Value of a is 10 Address location of a is 6422036 Value of p which is address location of a is 10 Address location of p is 6422024 Value at address location q(which is address location of p) is 6422036 Value at address location p(which is address location of a) is 10