हिंदी माध्यम नोट्स
Categories: C Language in hindi
Pointer As Array in hindi in c language पॉइंटर अर्रे की तरह कैसे कार्य करता है c कंप्यूटर भाषा हिंदी में
पॉइंटर अर्रे की तरह कैसे कार्य करता है c कंप्यूटर भाषा हिंदी में Pointer As Array in hindi in c language :-
इससे पहले के article मे ,array और pointer को पढ़ा है |अब इस article मे , हम article pointer का array के साथ सबंद को पड़ेगे :
1. Pointer With Array
जब कभी array को declare करते है तब complier कंप्यूटर memory मे base address को allocate करता है |और सभी elements के लिए proper memory space allocate करता है |
यहा पर base address का मतलब है array की first element का address |अतः array मे ,complier array_name को constant pointer की तरह काम करता है |
जैसे
int a[6]={1,2,3,4,5,6};
lets suppose , array ‘a’ first element का first element का address 2000 है |इसलिए array का type integer होता है|इसलिय
array element ‘1’ का address ‘2000’ है |
array element ‘2’ का address ‘2002’ है |
array element ‘3’ का address ‘2004’ है |
array element ‘4’ का address ‘2006’ है |
array element ‘5’ का address ‘2008’ है |
array element ‘6’ का address ‘2010’ है |
array name ‘a’ एक constant pointer की तरह कार्य करता है यह array के first element की address की value को contain करता है |जैसे
a=&a[0]=2000
हम कोई pointer को declare करता है जैसे
int*b;
b=a;
b=a; statement से array ‘a’ के first element का address 2000 pointer ‘b’ मे assign होता है|और आगे के लिए
a+1; ये array के second element के address को contain करता है |
a+2; ये array के third element के address को contain करता है |
a+3: ये array के fourth element के address को contain करता है |
a+4; ये array के fifth element के address को contain करता है|
a+5;ये array के सिक्स्थ element के address को contain करता है |
उदहारण के लिए:
#include<stdio.h>
#include,conio.h>
void main()
{
int *b,i;
int a[5]={2,4,56,4,5};
b=a;
int mul;
printf(“Element Address”)
for(i=0;i<5;i++)
{
printf(“%d %u\n”,**b,b);
mul=mul*a[i];
b++;
}
printf(“Mulplication Of elements=%d”,mul);
getch();
}
इस उदहारण मे printf(“%d %u”,**b,b); मे , *b का मतलब है pointer variable ‘p’ की pointer value और ‘p’ का मतलब है p का address है |अतः array के first element का address 2340 है tab आउटपुट होगा :-
Element Address
2 2340
4 2342
56 2344
4 2346
5 2348
Multiplication Of elements 8960
Two Dimensional Array
Two Dimensional Array मे, pointer को use कर सकते है |किसी one dimensional array मे ,pointer (*p+i) का use a[i] के address को store करने के लिए किया जाता है |अतः Two Dimensional Array के लिए pointer का syntax है |
जैसे
*(*a+i)+j और *(*b+i)+j
यह पर i और j की row और column की number को बताता है |
जैसे
i=1 और j=2 होने पर , pointer variable row 1, के colunm 2 के variable के address को store करता है |
i=2 और j=2 होने पर , pointer variable row 2, के colunm 2 के variable के address को store करता है |
i=3 और j=3 होने पर , pointer variable row 3, के colunm 3 के variable के address को store करता है |
Pointer and Character Strings :
string character का array होता है |इसे initial और declare का syntax है :-=
char a[23]= ‘Parth’;
complier आटोमेटिक string array के end मे null value को insert कर देता है |और C language मे ,pointer से भी string को declare कर सकते है |इसका syntax है :-
data type *string_name;
यहा:
datatype : string के लिए,हमेशा datatype charecter रहता है |
string_name : ये string का नाम होता है |
जैसे
char *name;
इसमें name एक string pointer है जो की ‘name’ string का first एलेमेनेट को point करता है |जैसे char *name=”parth”; मे string pointer name ‘p’ के address को point करता है |
normal string के साथ , run time assignment करना impossible है |लेकिंग string pointer मे हम run time assignment कर सकते है |जैसे
char *name;
name =”Parth”;
string pointer से string को print करने के लिए puts() और printf() function का use किया जाता है |
puts(name);
printf(“%s”,name );
यह पर ‘*’ operator की जरुरत नहीं होती है |
उदाहरण के लिए :
#include<stdio.h>
#include,conio.h>
void main()
{
int i;
int *name =”parth”;
printf(“Element Address”)
for(i=0;i<5;i++)
{
printf(“%c %u\n”,*name,name);
name++;
}
getch();
}
आउटपुट होगा :
Element Address
p 2340
a 2342
r 2344
t 2346
h 2348
Pointer As multiple strings
pointer का सबसे important use होता है multiple string को handle करना है |इसका syntax होता है :-
data type *string_name [number of string ];
यहा पर ,
data type : इसमें data type हमेशा character ही रहेगे|
string_name: ये string का नाम होता है |
number of string: ये number of string है जिसको string पोइंत्येर handle करता है |
जैसे
char *name[3];
इस उदाहरन मे ,name के string pointer variable है जो की तीन name को store कर सकता है |इसका initial होगा :-
char *name[2]={“parth”,”Om” ,”meet”};
इसमें name[0], string ‘parth’ के first element के address को contain करेगा|
और name [1],string ‘Om’ के first element के address को contain करेगा |
और name [2], string ‘meet’ के first element के address को contain करेगा |
अब next article मे pointer as function arguments को पड़ेगे |
Recent Posts
Question Tag Definition in english with examples upsc ssc ias state pcs exames important topic
Question Tag Definition • A question tag is a small question at the end of a…
2 weeks ago
Translation in english grammer in hindi examples Step of Translation (अनुवाद के चरण)
Translation 1. Step of Translation (अनुवाद के चरण) • मूल वाक्य का पता करना और उसकी…
2 weeks ago
Report Writing examples in english grammer How to Write Reports explain Exercise
Report Writing • How to Write Reports • Just as no definite rules can be laid down…
2 weeks ago
Letter writing ,types and their examples in english grammer upsc state pcs class 12 10th
Letter writing • Introduction • Letter writing is an intricate task as it demands meticulous attention, still…
2 weeks ago
विश्व के महाद्वीप की भौगोलिक विशेषताएँ continents of the world and their countries in hindi features
continents of the world and their countries in hindi features विश्व के महाद्वीप की भौगोलिक…
2 weeks ago
भारत के वन्य जीव राष्ट्रीय उद्यान list in hin hindi IAS UPSC
भारत के वन्य जीव भारत में जलवायु की दृष्टि से काफी विविधता पाई जाती है,…
2 weeks ago