Posts

NULL Pointer नल पॉइंटर

If a pointer variable stores a NULL value, then this type of pointer is called a NULL pointer. Initialization of a pointer with NULL indicates that the pointer does not point to any valid object or memory address. यदि किसी पॉइंटर वेरिएबल में NULL वैल्यू स्टोर की जाती है, तब इस प्रकार के पॉइंटर को नल पॉइंटर (NULL Pointer) कहा जाता है। पॉइंटर को NULL वैल्यू प्रदान करने पर वह किसी वैलिड ऑब्जेक्ट या मेमोरी एड्रेस को पॉइंट नहीं करता है। Syntax: data_type *pointer_name = NULL; Example: int *p = NULL; char *q = NULL; In the above example: p is an integer pointer initialized with NULL. q is a character pointer initialized with NULL. Both pointers do not point to any valid object. उपरोक्त उदाहरण में: p एक इन्टिजर पॉइंटर है जिसे NULL से इनिशियलाइज किया गया है। q एक करैक्टर पॉइंटर है जिसे NULL से इनिशियलाइज किया गया है। दोनों पॉइंटर किसी वैलिड ऑब्जेक्ट को पॉइंट नहीं करते हैं। Important Note: NULL and '\0' are different. NULL is used to represent a null pointer. '\0' is the...

Void Pointer वोइड पॉइंटर

A void pointer is a special type of pointer variable in C language. It is used when the programmer does not know or does not need to specify the data type of the variable whose memory address will be stored in the pointer. The void keyword is used to declare a void pointer in C language. सी लैंग्वेज में वोइड पॉइंटर एक विशेष प्रकार का पॉइंटर वेरिएबल होता है। इसका प्रयोग उस परिस्थिति में किया जाता है जब प्रोग्रामर को यह ज्ञात न हो या आवश्यकता न हो कि पॉइंटर में जिस वेरिएबल का एड्रेस स्टोर किया जाएगा, वह किस डाटा टाइप का है। सी लैंग्वेज में वोइड पॉइंटर डिक्लेयर करने के लिए void कीवर्ड का प्रयोग किया जाता है। Syntax: void *pointer_name; Example: void *p; In the above example, p is a void pointer variable which can store the memory address of a variable of any data type. उपरोक्त उदाहरण में p एक वोइड पॉइंटर वेरिएबल है जो किसी भी डाटा टाइप के वेरिएबल का मेमोरी एड्रेस स्टोर कर सकता है। C Program for Void Pointer #include <stdio.h> #include <conio.h> void main() { char a; ...

Array of Pointers अरे ऑफ पॉइंटर्स

 An array which stores pointer variables of the same data type as its elements is called an array of pointers. In other words, an array of pointers stores the memory addresses of different variables of the same data type. एक ऐसा ऐरे जो पॉइंटर वेरिएबल्स को अपने डेटा एलिमेंट्स के रूप में स्टोर करता है, अरे ऑफ पॉइंटर्स (Array of Pointers) कहलाता है। दूसरे शब्दों में, अरे ऑफ पॉइंटर्स के द्वारा उसी प्रकार के विभिन्न वेरिएबल्स के मेमोरी एड्रेस स्टोर किए जा सकते हैं। Syntax: data_type *array_name[size]; Example: float *ptr[3]; In the above example, ptr is an array of three pointers of float type. Each pointer can store the address of a float variable. उपरोक्त उदाहरण में ptr फ्लोट टाइप के तीन पॉइंटर्स का ऐरे है। प्रत्येक पॉइंटर किसी फ्लोट वेरिएबल का मेमोरी एड्रेस स्टोर कर सकता है। C Program for Array of Pointers #include <stdio.h> #include <conio.h> void main() { float a = 7.8, b = 13.5, c = 78.3; float *ptr[3]; clrscr(); ptr[0] = &a; ptr[1] = &...

Pointer to String पॉइंटर टू स्ट्रिंग or Pointer of String पॉइंटर ऑफ़ स्ट्रिंग or String Pointer स्ट्रिंग पॉइंटर

A pointer variable which stores the memory address of the first element or base address of a character array (string) is called a pointer to string or string pointer. एक करैक्टर टाइप का पॉइंटर वेरिएबल जो करैक्टर ऐरे या स्ट्रिंग के प्रथम एलिमेंट का मेमोरी एड्रेस स्टोर करता है, पॉइंटर टू स्ट्रिंग (Pointer to String) कहलाता है। Syntax: char array_name[size], *ptr_name; ptr_name = array_name; Example: char name[20], *p; p = name; In the above example, pointer p stores the base address of character array name , that is, the address of its first character. उपरोक्त उदाहरण में पॉइंटर p , करैक्टर ऐरे name का बेस एड्रेस अर्थात उसके पहले करैक्टर का मेमोरी एड्रेस स्टोर करता है। C Program for Pointer to String #include <stdio.h> #include <conio.h> void main() { char name[20], *p; clrscr(); printf("Enter name of a student:\n"); scanf("%19s", name); p = name; printf("Name of Student is = %s", p); getch(); } Output: Enter ...

Pointer to Union पॉइंटर टू यूनियन or Pointer of Union पॉइंटर ऑफ़ यूनियन or Union Pointer यूनियन पॉइंटर

A pointer variable of union type which stores the memory address of a union variable of the same type is called a pointer to union or union pointer. एक यूनियन टाइप का पॉइंटर वेरिएबल जो उसी प्रकार के यूनियन वेरिएबल का मेमोरी एड्रेस स्टोर करता है, पॉइंटर टू यूनियन (Pointer to Union) कहलाता है। To access the data members of a union using a union pointer, we use the arrow operator ( -> ). यूनियन पॉइंटर की सहायता से यूनियन के डेटा मेंबर्स को एक्सेस करने के लिए एरो ऑपरेटर ( -> ) का प्रयोग किया जाता है। Syntax Declaration: union union_name *ptr_name; Initialization: ptr_name = &union_variable_name; Accessing union members: ptr_name->data_member; C Program for Pointer to Union #include <stdio.h> #include <conio.h> union student { int roll_no; char name[20]; char gender; float fees; }; void main() { union student s, *p; p = &s; clrscr(); printf("Enter roll no of a student:\n"); scanf("%d", &p->roll_...

Pointer to Structure पॉइंटर टू स्ट्रक्चर or pointer of structure पॉइंटर ऑफ़ स्ट्रक्चर or structure pointer स्ट्रक्चर पॉइंटर

 A pointer variable of structure type which stores the memory address of a structure variable of the same type is called a pointer to structure or structure pointer. एक स्ट्रक्चर टाइप का पॉइंटर वेरिएबल जो उसी प्रकार के स्ट्रक्चर वेरिएबल का मेमोरी एड्रेस स्टोर करता है, पॉइंटर टू स्ट्रक्चर (Pointer to Structure) कहलाता है। To access the data members of a structure using a structure pointer, we use the arrow operator ( -> ). स्ट्रक्चर पॉइंटर की सहायता से स्ट्रक्चर के डेटा मेंबर्स को एक्सेस करने के लिए एरो ऑपरेटर ( -> ) का प्रयोग किया जाता है। Syntax Declaration: struct structure_name *ptr_name; Initialization: ptr_name = &struct_variable_name; Accessing structure members: ptr_name->data_member; C Program for Pointer to Structure #include <stdio.h> struct student { int roll_no; char name[20]; char gender; float fees; }; int main() { struct student s, *p; p = &s; printf("Enter details of student\n"); printf("Enter ro...

Pointer to Array पॉइंटर टू ऐरे or Pointer of Array पॉइंटरऑफ़ ऐरे or Array Pointer ऐरे पॉइंटर

A pointer variable which stores the base address of an array of the same data type is commonly used to access the elements of that array. It is explained as a pointer to array in introductory C programming. एक पॉइंटर वेरिएबल जो उसी डाटा टाइप के ऐरे के पहले एलिमेंट का मेमोरी एड्रेस स्टोर करता है, उसे सामान्यतः पॉइंटर टू ऐरे के रूप में समझाया जाता है। Syntax: data_type array_name[size], *ptr_name; ptr_name = array_name; Example: int list[5], *p; p = list; In the above example, pointer p stores the base address of array list , that is, the address of its first element list[0] . उपरोक्त उदाहरण में पॉइंटर p , ऐरे list का बेस एड्रेस अर्थात उसके पहले एलिमेंट list[0] का मेमोरी एड्रेस स्टोर करता है। C Program for Pointer to Array #include <stdio.h> #include <conio.h> void main() { int list[5], *p, i; clrscr(); printf("Enter five integer numbers:\n"); for(i = 0; i < 5; i++) { scanf("%d", &list[i]); } p = list; ...