Pointer arithmetic in hindi
सी लैंग्वेज में पॉइंटर अर्थमेटिक ऑपरेशन C और C++ जैसी लैंग्वेजेज में एक बेसिक फंडामेंटल प्रोग्रामिंग कांसेप्ट है. जिसमें डायरेक्ट सी प्रोग्राम वेरिएबल मेमोरी मैनेजमेंट फीचर्स मिलते है। यह सी प्रोग्रामर को ऐरे और अन्य डेटा स्ट्रक्चर ऑपरेशन्स को कुशलतापूर्वक नेविगेट करने और उन्हें मैनेज करने के लिए पॉइंटर्स में स्टोर मेमोरी एड्रेस में हेरफेर करने की अनुमति देता है।

So let’s know what is pointer arithmetic in C.
Pointer Definition and Dereferencing in C.
सी लैंग्वेज में एक पॉइंटर एक मेमोरी वैरिएबल और उसका स्टोरेज एड्रेस है. जो किसी दूसरे प्रोग्राम में डिक्लेअर वैरिएबल के मेमोरी एड्रेस लोकेशन को स्टोर करता है।
सी लैंग्वेज में पॉइंटर डीरेफ़रेंसिंग का अर्थ है की प्रोग्राम में डिक्लेअर पॉइंटर वेरिएबल द्वारा स्टोर किये गए मेमोरी एड्रेस पर स्टोर किए गए वैल्यू की जानना है।
int p = 9;
int *ptr = &p; // Here ‘ptr’ variable now holds the address of ‘p’
int info = *ptr; // Here the variable ‘info’ now holds the value 10.
Pointer Addition and Subtraction Operations in C.
याद रहे की सी लैंग्वेज में पॉइंटर में एक इन्टिजर जोड़ने से यह बाइट्स नहीं बल्कि स्टोर ऐरे एलिमेंट्स नंबर में आगे बढ़ता है।
वही ऐरे में पॉइंटर से एक इन्टिजर वैल्यू घटाने से यह ऐरे एलिमेंट की संख्या से कम करता है।
int arrinfo[] = {9, 5, 8, 3, 2};
int *ptr = arrinfo; // ‘arrinfo’ indicates the first stored element of the array
ptr++; // Now ptr indicates the second stored element ‘5’ (arrinfo[1])
ptr–; // Here now ptr indicates the second stored array element ‘9’ (arrinfo[0])
ptr += 3; // Now points to the array element at ‘2’ (arrinfo[4])
Pointer Difference in C.
पॉइंटर डिफ्रेंस इन सी में एक पॉइंटर को दूसरे में से घटाने पर उनके बीच ऐरे वेरिएबल एलिमेंट की वैल्यूज फाइंड की जाती है।
int *start = arrinfo; // This indicates the first array index element arrinfo[0].
int *end = arrinfo + 4; // This indicates the last 4th array element in arrinfo[4].
int distance = end – start; // This indicates that the ‘distance’ between the first and last array element index is 4.
Comparison of Pointers in C.
सी लैंग्वेज में पॉइंटर को ==, !=, <, >, आदि जैसे रिलेशनल ऑपरेटरों का उपयोग करके पॉइंटर्स वेरिएबल के बिच तुलना की जा सकती है।
याद रखे की पॉइंटर तुलनाएँ तभी वैलिड होती हैं, जब पॉइंटर्स एक ही ऐरे एलिमेंट या मेमोरी ब्लॉक के एलिमेंट में डिस्प्ले या स्टोर हो।
if (start < end) {
// when it find condition true, it display result
}
Pointer Arithmetic on Different Types in C.
यदि आप किसी सी प्रोग्राम में पॉइंटर अर्थमेटिक ऑपरेशन करना चाहते है. तो आपको पॉइंटर अंकगणित का परिणाम पॉइंटर के उपयोग होने वाले डाटा टाइप पर अलग अलग हो सकता है।
यदि आप किसी पॉइंटर को char डाटा टाइप में पॉइंटर ऑपरेशन बढ़ाने पर वह 1 करैक्टर बाइट आगे बढ़ता है. जबकि यदि किसी पॉइंटर को int इन्टिजर डाटा टाइप में बढ़ाने पर वह 4 बाइट्स आगे बढ़ता है।
char *charptrinfo = (char *) array; // Declaring ‘arr’ as a char character array.
int *intptrinfo = array; // Declaring ‘array’ as an integer array.
charptrinfo += 1; // It moves forward by 1 byte in the memory
intptrinfo += 1; // moves forward by 4 bytes (or sizeof(int) bytes)