পয়েন্টারের অ্যারে (স্ট্রিংগুলিতে)
পয়েন্টারগুলির অ্যারে হল একটি অ্যারে যার উপাদানগুলি স্ট্রিংয়ের বেস ঠিকানার নির্দেশক৷
এটি নিম্নরূপ ঘোষিত এবং সূচনা করা হয় -
char *a[3 ] = {"one", "two", "three"};
//Here, a[0] is a ptr to the base add of the string "one"
//a[1] is a ptr to the base add of the string "two"
//a[2] is a ptr to the base add of the string "three" সুবিধা
-
অক্ষরের দ্বি-মাত্রিক অ্যারে লিঙ্কমুক্ত করুন। (স্ট্রিং এর অ্যারে), স্ট্রিং এর পয়েন্টার এর বিন্যাসে স্টোরেজের জন্য কোন নির্দিষ্ট মেমরি সাইজ নেই।
-
স্ট্রিংগুলি প্রয়োজনীয় যত বাইট দখল করে তাই স্থানের কোন অপচয় হয় না৷
উদাহরণ 1
#include<stdio.h>
main (){
char *a[5] = {“one”, “two”, “three”, “four”, “five”};//declaring array of pointers to
string at compile time
int i;
printf ( “The strings are:”)
for (i=0; i<5; i++)
printf (“%s”, a[i]); //printing array of strings
getch ();
} আউটপুট
The strings are: one two three four five
উদাহরণ 2
স্ট্রিং-
-এর জন্য পয়েন্টার অ্যারের আরেকটি উদাহরণ বিবেচনা করুন#include <stdio.h>
#include <String.h>
int main(){
//initializing the pointer string array
char *students[]={"bhanu","ramu","hari","pinky",};
int i,j,a;
printf("The names of students are:\n");
for(i=0 ;i<4 ;i++ )
printf("%s\n",students[i]);
return 0;
} আউটপুট
The names of students are: bhanu ramu hari pinky