C_76 Pointers in C- part 6 | Pointer Arithmetic (Subtraction) with program

Jenny's Lectures CS IT
13 Aug 202117:48

Summary

TLDRThe video script discusses learning programming in C, focusing on pointer variables, pointer arithmetic, and how to manipulate pointers to access array elements. It explains the concepts of pointer subtraction, pointer addition, and how to use pointers to perform operations on arrays, emphasizing the importance of understanding pointer arithmetic for effective programming.

Takeaways

  • 😀 The video discusses learning programming in C, specifically focusing on pointers and how to handle them in various scenarios.
  • 🔍 It explains how to declare and initialize pointers, including the difference between pointer variables and actual pointers.
  • 📚 The script covers how to perform operations on pointers, such as pointer arithmetic and how to access values through pointers.
  • 👨‍🏫 It demonstrates how to use pointers to access array elements, including how to calculate the address of elements and how pointers can be used to iterate through arrays.
  • 🔢 The video clarifies the concept of pointer arithmetic, showing how to add or subtract integers from pointers to move them through memory.
  • 💡 It discusses the importance of understanding the size of data types when performing pointer arithmetic to avoid undefined behavior.
  • 📌 The script highlights the use of pointers in functions, explaining how to pass pointers to functions and how to return pointers from functions.
  • 🚀 The video also touches on the concept of pointer subtraction, explaining how to find the difference between two pointers and what this difference represents in terms of memory.
  • 🛠️ It provides examples of pointer operations, including how to increment and decrement pointers and how these operations can be used in practical programming.
  • 🔎 The script emphasizes the need for careful handling of pointers to avoid issues like segmentation faults and undefined behavior, especially when dealing with pointer arithmetic and memory allocation.

Q & A

  • What is the main topic being discussed in the script?

    -The main topic discussed in the script is the concept of pointers in programming, specifically how to handle and manipulate pointer variables in C.

  • What is a pointer variable?

    -A pointer variable is a variable that stores the memory address of another variable. It is used to indirectly access the value stored at the memory location it points to.

  • What is the difference between a pointer variable and an integer variable?

    -A pointer variable stores the memory address of another variable, while an integer variable stores a numerical value. Pointers are used to access and manipulate memory addresses, whereas integers are used to store and perform arithmetic operations on numbers.

  • How can you assign the address of an integer variable to a pointer variable?

    -You can assign the address of an integer variable to a pointer variable using the address-of operator (&). For example, `int *p = &a;` assigns the address of `a` to the pointer `p`.

  • What is the purpose of pointer arithmetic?

    -Pointer arithmetic is used to move a pointer to different memory locations. It allows programmers to access elements in arrays or other data structures by incrementing or decrementing the pointer.

  • How can you find the difference between two pointers?

    -The difference between two pointers can be found by subtracting one pointer from another. This gives the number of elements between the two pointers, considering the size of the data type they point to.

  • What is the significance of pointer subtraction?

    -Pointer subtraction is significant because it helps in determining the number of elements between two pointers. This is useful when working with arrays or other data structures where you need to calculate offsets.

  • Can you use pointer arithmetic with different data types?

    -Pointer arithmetic is generally performed with pointers of the same data type. Mixing pointers of different data types can lead to undefined behavior or incorrect results.

  • What happens when you subtract one pointer from another?

    -When you subtract one pointer from another, the result is the number of elements between the two pointers, not the difference in their memory addresses. The result is an integer value.

  • How can you access the value pointed to by a pointer?

    -You can access the value pointed to by a pointer using the dereference operator (*). For example, `int value = *p;` retrieves the value stored at the memory address pointed to by `p`.

  • What is the relationship between pointer variables and memory addresses?

    -Pointer variables hold the memory addresses of other variables. They act as a reference or link to the memory location where the data is stored, allowing indirect access to the data.

Outlines

00:00

😀 Understanding Pointers and Array Elements

This paragraph discusses the concept of pointers in programming, focusing on how to manipulate and access array elements using pointers. It explains the process of subtracting one pointer from another to find the difference in terms of array elements. The speaker also covers the use of pointer arithmetic to navigate through an array, including moving pointers forward and backward. The importance of understanding the base address and how to calculate the address of specific elements within an array is emphasized. Additionally, the paragraph touches on the potential for undefined behavior when pointers are used incorrectly, such as accessing memory locations that are out of bounds.

05:02

😉 Pointer Arithmetic and Memory Access

The second paragraph delves deeper into pointer arithmetic, explaining how to calculate the difference between pointers and the implications of this calculation. It discusses the use of pointer subtraction to determine the number of elements between two pointers. The speaker clarifies that subtracting one pointer from another yields an integer value representing the distance in elements, not bytes. The paragraph also addresses the concept of dividing this difference by the size of the data type to find the number of elements. The potential for incorrect calculations and the resulting undefined behavior when accessing memory outside the intended range is highlighted, emphasizing the need for careful pointer manipulation.

10:05

🎓 Advanced Pointer Operations and Memory Management

This paragraph explores advanced operations with pointers, including how to find the difference between pointers and the significance of this in memory management. It discusses the logic behind finding the difference between two pointers and why it is essential for managing memory effectively. The speaker explains the use of pointer subtraction to determine the number of elements between two memory locations and how this can lead to undefined behavior if the pointers are not properly managed. The paragraph also touches on the concept of constant pointers and how they are used in programming. The speaker advises on the practical application of these concepts and encourages the creation of a file to demonstrate pointer subtraction and its results.

15:05

📚 Increment and Decrement Operators on Pointers

The final paragraph focuses on the use of increment and decrement operators on pointers, explaining how these operators can be applied to navigate through arrays. It discusses the practical application of these operators in programming, including how to use them to move pointers to different elements within an array. The speaker provides examples of how to use these operators to increment and decrement pointers, demonstrating the effects on the pointer's position within the array. The paragraph also addresses the potential for undefined behavior when using these operators incorrectly, such as moving a pointer outside the bounds of the array. The speaker concludes by encouraging viewers to apply these concepts in their programming practice.

Mindmap

Keywords

💡Pointer

A pointer is a variable that stores the memory address of another variable. In the video, pointers are used to navigate through elements of an array and perform arithmetic operations. Examples include using 'p' to store the address of the first element of an array and 'q' to store the address of the third element.

💡Array

An array is a collection of elements identified by index or key. In the video, the array 'a' is used to demonstrate pointer arithmetic, where 'p' and 'q' point to different elements within the array. For example, 'a[0]' stores the value at the first index of the array.

💡Pointer Arithmetic

Pointer arithmetic involves operations such as addition or subtraction on pointers to navigate through an array. The video discusses adding or subtracting integers from pointers, and finding the difference between two pointers. For instance, 'q - p' calculates the number of elements between the two pointers.

💡Memory Address

A memory address is a specific location in memory where data is stored. The video demonstrates how pointers store memory addresses, such as 'p' storing the address of 'a[0]', which is '1000'. Memory addresses are crucial for understanding how pointers work.

💡Subtraction of Pointers

This concept involves calculating the difference between two pointer variables. The video explains that subtracting pointers gives the number of elements between them. For example, 'q - p' results in '3' when 'q' points to 'a[3]' and 'p' points to 'a[0]'.

💡Addition of Pointers

Adding an integer to a pointer shifts the pointer by that many elements in the array. The video explains that 'p + 2' moves the pointer 'p' forward by two elements, changing its address from '1000' to '1008' when each element is 4 bytes.

💡Size of Data Type

The size of a data type, like 'int', determines how many bytes each element occupies in memory. The video mentions that an integer takes up 4 bytes, which is essential for pointer arithmetic calculations, such as determining the new address after addition or subtraction.

💡Base Address

The base address is the memory address of the first element in an array. In the video, the base address of array 'a' is stored in pointer 'p'. This address serves as a reference point for other pointer operations within the array.

💡Pointer to Array Element

This refers to a pointer that holds the address of a specific element within an array. The video shows 'p' pointing to 'a[0]' and 'q' pointing to 'a[3]', illustrating how pointers can reference different elements of the same array.

💡Undefined Behavior

Undefined behavior occurs when code executes in a way that is unpredictable or not defined by the language standard. The video warns that accessing memory outside the bounds of an array (e.g., 'q - 2' when 'q' points to an invalid location) can result in undefined behavior, leading to garbage values.

Highlights

Introduction to learning programming with a focus on pointers and arrays.

Explanation of pointer variables and how to use them to access array elements.

Demonstration of pointer arithmetic and its application in programming.

How to increment and decrement pointers to navigate through memory.

Understanding the difference between pointer variables and integer values.

The concept of pointer subtraction and its use in calculating memory offsets.

Pointers to pointers and their role in complex data structures.

Memory allocation and the importance of managing memory in programming.

How to use pointers to access the base address of an array.

The relationship between pointers and array indexing.

Safety considerations when performing pointer arithmetic.

Pointers and their role in dynamic memory allocation.

Examples of pointer usage in real-world programming scenarios.

Common pitfalls to avoid when working with pointers.

Advanced pointer techniques for optimizing performance.

Debugging strategies for pointer-related errors in code.

The impact of pointers on the efficiency of algorithms.

Conclusion and summary of key takeaways from the discussion on pointers.

Transcripts

play00:00

सो इन द सीरीज ऑफ लर्निंग प्रोग्रामिंग इन

play00:02

सी वी आर डिस्कसिंग

play00:03

अरिमिल्ली

play00:18

ऐड एन इंटी जर टू अ पॉइंटर दैट वी हैव

play00:21

डिस्कस इन प्रीवियस वीडियो विद प्रॉपर

play00:23

एग्जांपल एंड प्रोग्राम सो नाउ यस वी कैन

play00:26

सबस्टैक टू पॉइंटर वेरिएबल वन पॉइंटर

play00:29

वेरिएबल फ्रॉम अदर पॉइंटर और यू कैन से वन

play00:31

पॉइंटर फ्रॉम अनदर पॉइंटर राइट और वी कैन

play00:33

सबै एनी इंटी जर वैल्यू आल्सो फ्रॉम अ

play00:36

पॉइंटर वेरिएबल बोथ द केसेस वी विल डिस्कस

play00:38

हियर विद हेल्प ऑफ प्रोग्राम एंड आई विल

play00:39

शो यू द कोड आल्सो नाउ लेटस परफॉर्म सबक्स

play00:42

ऑपरेशन ऑन पॉइंटर हेयर आई एम टेकिंग सी इफ

play00:47

आई एम डायरेक्टली टेकिंग एन एरे राइट एंड

play00:51

आई एम टेकिंग साइज जज सपोज आई एम नॉट

play00:53

डिक्लेयर हेयर साइज सो अल्टीमेटली इफ यू

play00:56

टेक फाइव वेरिएबल अल्टीमेटली द साइज वुड

play00:58

बी फाइव सो सो हियर आई एम टेकिंग वन

play01:01

पॉइंटर p राइट एंड इन प आई एम स्टोरिंग

play01:04

एड्रेस ऑफ ए सिंपली यू कैन राइट ए आल्सो

play01:07

हेयर बिकॉज ए इज नेम ऑफ द एरे एंड ए इज

play01:10

आल्सो कंटेनिंग एड्रेस ऑफ द फर्स्ट

play01:12

एलिमेंट और द बेस एड्रेस सो दिस इज आल्सो

play01:14

फाइन और यू कैन राइट एड्रेस ऑफ a ऑफ 0 दिस

play01:19

इज आल्सो फाइन राइट एंड वन मोर पॉइंटर आई

play01:22

एम टेकिंग इंट एट्रिक q एंड हेयर इन दिस

play01:26

पॉइंटर इन दिस पॉइंटर व्हाट आई एम

play01:27

स्टोरिंग आई एम स्टोरिंग एड्रेस ऑफ सपोज

play01:31

थर्ड

play01:32

एलिमेंट ऑफ द अरे सो आई एम हेयर टेकिंग टू

play01:35

पॉइंटर सो हेयर इफ प एंड q आर टू पॉइंटर

play01:38

देन सबक्स p माइ q इज इट पॉसिबल यस पॉसिबल

play01:41

q माइन प q माइ प इट इज पॉसिबल यस पॉसिबल

play01:45

बट इन केस ऑफ सबक्स p प् q इफ बोथ आर

play01:48

पॉइंटर वेरिएबल नॉट

play01:50

पॉसिबल राइट एंड हेयर p माइनस एनी इंटी जर

play01:54

वैल्यू दैट इज पॉसिबल यस पॉसिबल सो बोथ द

play01:57

केसेस आर पॉसिबल इन केस ऑफ सक्शन राइट वी

play02:01

विल डिस्कस वन बाय वन दिस थिंग सो सम

play02:04

मेमोरी हैज बीन एलोकेटेड टू दिस ए सपोज

play02:07

दिस इज अ

play02:12

एरे सो हेयर वी हैव टू पॉइंटर प प इन प वी

play02:16

हैव एड्रेस ऑफ a ऑफ 0 एड्रेस ऑफ a ऑफ 0 इज

play02:18

a ऑफ 0 सी दिस इज एलिमेंट आई मीन द वैल्यू

play02:22

सपोज आई एम टेकिंग वैल्यू 50 वैल्यू इ 50

play02:26

सो a ऑफ 0 इंडेक्स जीरो हेयर वी हैव 1000

play02:29

सो इट इज पॉइंट टू दिस वन एंड इन क वी हैव

play02:32

एड्रेस ऑफ a ऑफ थ थर्ड इंडेक्स एड्रेस जज

play02:35

102 सो इट इज पॉइंट ंग टू हियर टू पॉइंट्स

play02:39

वी हैव एंड ए इज ओबवियसली इंटरनल और यू

play02:42

कैन से कांस्टेंट पॉइंटर व्हिच इज

play02:43

कंटेनिंग बेस एड्रेस ऑफ दिस एरे दैट इज

play02:46

1000 राइट एंड आई एम टेकिंग बाय डिफॉल्ट

play02:48

इंटी जर इज टेकिंग फोर बाइट्स राइट सो दीज

play02:51

आर द एड्रेस ऑफ द ऑल द एलिमेंट्स ऑफ द एरे

play02:53

नाउ इफ इफ यू वांट टू फाइंड आउट द डिफरेंस

play02:57

ऑफ p एंड q देन हाउ यू कैन डू इफ यू राइट

play03:00

समथिंग लाइक दिस सपोज आई एम फाइंडिंग डी

play03:03

आई एम टेकिंग अ वेरिएबल डी एंड आई एम

play03:06

डिक्लेयर हियर इंट

play03:07

d द डिफरेंस वुड बी इंटी जर वैल्यू यू विल

play03:12

गेट राइट सी इफ यू डू p p+ 2 मींस इन केस

play03:19

ऑफ एडिशन द रिजल्ट यू विल गेट इन फॉर्म ऑफ

play03:24

पॉइंटर राइट इफ हियर p इज 1000 प् 2 इफ यू

play03:28

विल डू इट मींस यू विल मूव दिस पॉइंटर

play03:31

फॉरवर्ड बाय टू एलिमेंट्स राइट टू

play03:35

एलिमेंट्स मींस वन एंड टू ् टू इन सिंपल

play03:38

टर्म इफ यू अंडरस्टैंड वन एंड टू सो p इज

play03:40

पॉइंट टू हियर सो अल्टीमेटली इट विल गिव

play03:43

1008 मींस इट इज गिविंग पॉइंटर

play03:46

ओनली और यू कैन से एड्रेस राइट द रिजल्ट

play03:50

वुड बी अ पॉइंटर एडिशन रिजल्ट बट सबट क्शन

play03:54

रिजल्ट वुड बी एनी इंटी जर

play03:56

वैल्यू 0 1 2 3 4 दिस काइंड ऑफ़ थिंग नॉट

play03:59

एड्रेस एनी इंटी जर वैल्यू राइट इफ यू

play04:03

सबक्स q और q - p राइट इफ यू सबस्टैक टू

play04:07

पॉइंट्स बट इफ यू सबै एनी इंटी जर वैल्यू

play04:11

फ्रॉम अ पॉइंटर दिस विल गिव यू रिजल्ट वुड

play04:14

बी इन पॉइंटर फॉर्म और एड्रेस यू विल गेट

play04:17

एड्रेस ऑफ द य नो एलिमेंट व्हिच आर टू

play04:22

पोजीशन बिहाइंड टू दिस p दैट वी विल

play04:25

डिस्कस

play04:26

आल्सो राइट नाउ इफ इन डी इफ आई वांट टू डू

play04:30

लाइक दिस q -

play04:33

p सो नाउ व्हाट वुड बी द आंसर इन q आई हैव

play04:36

1012 माइनस इन p आई हैव 1000 सो आई थिंक

play04:41

यू अ यू आर थिंकिंग दैट आंसर वुड बी

play04:44

12 बट 12 इज़ नॉट मेकिंग एनी सेंस व्हाट

play04:48

आंसर यू विल गेट

play04:50

हियर सी द डिफरेंस एंड यू हैव टू डिवाइड

play04:54

इट बाय द साइज ऑफ़ डेटा टाइप साइज इज वट

play04:56

इंटी जर एंड साइज़ ऑफ़ डेटा टाइप इज़ इंटी

play04:58

जर इज़ फोर सो अल्टीमेटली यू विल गेट

play05:02

थ्री सो दिस विल गिव यू थ्री थ्री

play05:05

मींस द एलिमेंट्स बिटवीन दीज टू हाउ मेनी

play05:09

हाउ मेनी एलिमेंट्स आर देयर बिटवीन दज टू

play05:11

वन टू एंड थ्री सो मींस p एंड q दज टू

play05:15

पॉइंट्स आर यू कैन से थ्री एलिमेंट्स

play05:19

अपार्ट राइट 12 इज नॉट मेकिंग एनी सेंस

play05:23

हेयर राइट आई होप यू गट दिस सो यू हैव टू

play05:26

डिवाइड इट बाय साइज ऑफ द डेटा टाइप राइट

play05:29

सो आई होप यू व्हेन यू सबकट टू पॉइंट्स

play05:32

व्हाट यू विल गेट हाउ मेनी एलिमेंट्स आर

play05:36

देयर बिटवीन दोज टू पॉइंट्स दैट यू विल

play05:38

गेट राइट सो नाउ और यू कैन आल्सो डू लाइक

play05:42

दिस p-q दिस इज आल्सो फाइन इफ यू डू p - q

play05:47

ओबवियसली यू विल गेट -3 राइट p इज व्हाट

play05:51

1000 - 1012 दैट इज -1 एंड इट वुड बी

play05:55

डिवाइडेड बाय व्हाट साइज ऑफ द डेटा टाइप

play05:58

दैट इज फोर सो यू विल गेट

play06:00

-3 राइट सो दैट इज द डिफरेंस दिस इज हाउ

play06:06

यू कैन फाइंड आउट द डिफरेंस बिटवीन टू

play06:08

पॉइंटर वेरिएबल बट हेयर इफ यू डू समथिंग

play06:11

लाइक दिस इफ आई डू p इ p सॉरी q इ इक्वल

play06:15

टू आई एम डूइंग q -

play06:19

2 नाउ व्हाट आंसर यू विल गेट दिस आंसर यू

play06:22

विल गेट इन इंटी जर फॉर्म दिस आंसर हाउ यू

play06:25

विल गेट द रिजल्ट वुड बी इन इंटी जर फॉर्म

play06:27

नो हेयर यू विल गेट अ पॉइंटर यू विल गेट

play06:30

एड्रेस सी q इज व्ट

play06:33

102 माइनस 2 मींस यू आर थिंकिंग यू विल

play06:37

गेट 10 10 नो दिस इज

play06:42

रंग मींस इन सिंपल टर्म्स इफ आई से यू हैव

play06:46

टू मूव बैकवर्ड डायरेक्शन बाय टू पोजीशन

play06:50

मींस वन एंड टू सो अल्टीमेटली नाउ क्य वड

play06:54

पॉइंट टू हेयर सो अल्टीमेटली द एड्रेस वुड

play06:56

बी 104 यू शुड गेट सो हाउ य विल गेट द

play06:59

फॉर्मूला वुड बी q इज हैविंग दिस वन -2 इन

play07:04

साइज ऑफ डेटा टाइप साइज इज 4 तो माइ 8 सो

play07:09

हेयर यू विल गेट व्ट

play07:11

1004 राइट इफ यू आस्क इफ यू आर आस्क

play07:14

एक्सप्लीसिटली दैट व्हाट शुड बी द एड्रेस

play07:16

देन यू हैव टू डू समथिंग लाइक दिस एंड यू

play07:18

हैव टू टेल अदर वाइज सिंपली इफ q -2 मूव

play07:22

टू पोजीशन बैकवर्ड ट्स इट टू य विल पॉइंट

play07:28

यर इ डू लाइक p इ p+ 2 प्लस मूव टू पोजीशन

play07:34

फॉरवर्ड p प् 2 मींस p इज हेयर नाउ वन एंड

play07:38

टू सो प वड पॉइंट ट हेयर इफ यू आर आस्क

play07:41

लाइक व्ट वुड बी द एड्रेस देन यू हैव टू

play07:44

यूज द फार्मूला एंड यू हैव टू कैलकुलेट द

play07:46

एड्रेस राइट सो सेम ट व्ट वुड बी द

play07:50

फार्मूला इफ q इफ अ पॉइंटर इज q माइनस n

play07:54

देन इट शुड बी q - n

play07:56

इन साइज ऑफ द डेटा टाइप

play08:01

दिस इज द फार्मूला राइट टू कैलकुलेट

play08:03

एड्रेस आफ्टर सबिंग सो इट विल गिव व्ट इट

play08:07

विल गिव व्ट q-2 इज 1004 एंड 104 इज

play08:11

एड्रेस सो रिजल्ट ऑफ दिस वुड बी एड्रेस और

play08:14

पॉइंटर रिटर्निंग रिजल्ट वड बी पॉइंटर एंड

play08:18

दिस विल गिव ए इन

play08:19

वैल्यू इट मींस प एंड q आर हाउ मेनी

play08:23

एलिमेंट्स अपार्ट फ्रॉम ईच अदर थ 4 दिस

play08:26

थिंग राइट नाउ हेयर q = q-2 फाइनली q इज

play08:30

नाउ हैविंग एड्रेस 1004 एंड q इज नाउ

play08:33

पॉइंट टू दिस नाउ इफ यू फाइंड डिफरेंस इज

play08:37

इक्व p - q देन व्हाट यू विल गेट हेयर वी

play08:41

हैव q हेयर वी हैव p p - q शुड बी दज आर

play08:45

वन एलिमेंट अपार्ट बट इट्स p माइ q दैट इज

play08:49

इट शुड बी -1 1000 माइन 1004 दैट इज -4 /

play08:54

4 -1 सो आफ्टर दैट इट विल गिव रिजल्ट -1

play08:58

और q - p p इफ यू डू दैट इट विल गिव वन सो

play09:02

आई होप यू गॉट हाउ सबट क्शन वुड बी डन

play09:05

राइट एंड इफ इफ आफ्टर दिस यू विल डू p = p

play09:09

-

play09:10

1 नाउ p इज व्हाट हियर इफ यू डू p - 1

play09:14

मींस यू आर मूविंग p इन बैकवर्ड डायरेक्शन

play09:16

वन पोजीशन वी डोंट हैव एनीथिंग हियर ऑब्

play09:19

वियस मेमोरी लोकेशन वुड बी देयर दैट वुड

play09:21

बी -4 दैट इज आई थिंक

play09:24

996 सो इफ यू टेक दिस एड्रेस देन इट विल

play09:28

गिव 996 बट इफ यू एक्सेस दिस देन देयर इज

play09:31

नो यू नो वी डोंट नो व्हाट इज देयर इन दिस

play09:33

मेमोरी लोकेशन सो इट विल गिव सम गार्बेज

play09:35

वैल्यू राइट सो बेटर टू मूव पॉइंटर विद इन

play09:39

दिस रेंज ओनली राइट बिकॉज अदर वाइज इफ यू

play09:43

मूव दिस और इफ यू मूव बियोंड दिस देन इट

play09:46

विल शो सम अनडिफाइंड बिहेवियर इट विल गिव

play09:49

सम यू नो गार्बेज वैल्यू राइट एंड वन मोर

play09:55

थिंग इफ टू पॉइंट इफ वी आर हैविंग टू एरे

play09:58

सपोज वन इज दिस एरे एंड अनदर एरे आई एम

play10:01

टेकिंग इंट बी एंड हेयर आल्सो आई एम

play10:04

टेकिंग टूथ ओनली थ्री वेरिएबल एंड नाउ q

play10:09

इज हैविंग एड्रेस ऑफ q इज हैविंग एड्रेस

play10:12

ऑफ बी ऑफ

play10:14

0 मींस प इज पॉइंट टू दिस ए एंड नाउ q इज

play10:18

पॉइंट टू दिस बी टू डिफरेंट डिफरेंट अरेज

play10:21

एंड इफ हेयर यू विल डू p-q और q - p मींस

play10:25

इट इज नॉट मेकिंग एनी सेंस इट विल गिव सम

play10:28

अनडिफाइंड इट विल शो अनडिफाइंड बिहेवियर

play10:30

बिकॉज प इज पॉइंट टू दिस q इज पॉइंट टू

play10:32

दिस सो व्हाट्स द यूज ऑफ फाइंडिंग द

play10:35

डिफरेंस बिटवीन दज टू वी डोंट नो इन

play10:36

मेमोरी मे बी सी दिस इज र मेमोरी समथिंग

play10:41

लाइक

play10:45

दिस सो हेयर मे बी सपोज हेयर वी हैव दिस

play10:48

एरे ए और इन मेमोरी सम वेयर आई डोंट नो

play10:50

हेयर वी हैव दिस एरे बी सो वई यू आर एंड प

play10:55

इज पॉइंट टू दिस एंड q इज पॉइंट टू दिस

play10:58

एंड इन बिटवीन दिस वी डोंट नो हाउ मेनी यू

play11:00

नो मेमोरी लोकेशंस आर देयर और व्हाट इज

play11:02

देयर व्ट डेटा इज स्टोर्ड हियर वी डोंट नो

play11:04

सो व्हाट्स द लॉजिक टू फाइंड डिफरेंस

play11:06

बिटवीन पी एंड क इफ बोथ आर पॉइंट टू सेम

play11:09

एरे देन इट्स मीनिंगफुल टू फाइंड डिफरेंस

play11:12

ऑफ दज टू पॉइंट्स अदर वाइज इट्स मीनिंग

play11:15

लेस सो नाउ दिस इज क्वेश्चन फॉर यू आई एम

play11:18

हैविंग ओनली वन एरे ए प इ स्टोरिंग एड्रेस

play11:21

ऑफ a ऑफ 0 q इज स्टोरिंग एड्रेस ऑफ a ऑ 4

play11:24

राइट एंड नाउ यू हैव टू प्रिंट द डिफरेंस

play11:26

फर्स्ट ऑफ ऑल देन दिस वुड बी अ

play11:30

25 देन अगेन यू हैव टू फाइंड द डिफरेंस

play11:32

देन ए प इ 27 देन q इ q माइ 3 एंड p = प

play11:36

प् 3 एंड नाउ अगेन आई एम फाइंडिंग इ p-q

play11:40

नाउ यू हैव टू टेल मी व्ट वड बी द आंसर ऑफ

play11:42

दज लाइंस एटलीस्ट यू शुड ट्राई इट एट योर

play11:44

ओन सो नाउ लेट मी यनो शो द प्रैक्टिकल ऑफ

play11:47

दिस थिंग सो नाउ लेट म क्रिएट अ

play11:51

फाइल

play11:53

पॉइंटर सबकट डट सी

play11:57

राइट

play12:06

मेन फंक्शन व्ट व विल राइट स र आम टेकिंग

play12:10

ट सॉरी वन एरे ट ज जस्ट इलांग ट हेयर 2

play12:18

430 माइन से समथिंग लाइक दिस राइट एंड

play12:23

हेयर वी आर टेकिंग टू पॉइंटर वन

play12:26

इ स्टार प एंड र लाइजिंग वट सिंपली आम

play12:30

राइटिंग ए राइट वन मोर पॉइंटर आईम टेकिंग

play12:34

क एंड हेयर आ एम स्टोरिंग एड्रेस ऑफ ए

play12:38

ऑफ

play12:40

3 राइट सो ए मींस ए मींस इट विल पॉइंट टू

play12:46

द बेस एड्रेस लाइक फर्स्ट एलिमेंट ऑफ दिस

play12:48

री सो नाउ हेयर जस्ट फाइंड आउट फर्स्ट ऑफ

play12:51

ल लेट्स फाइंड आउट द डिफरेंस प्रिंट

play12:56

एफ q माइन प

play12:59

इ इक्वल टू परसेंटेज बिक इट विल गव इंजर

play13:03

सो परसेंटेज एंड र सिपली राइटिंग माइन

play13:07

प राइट एंड वन मोर थिंग प्रिंट एफ एंड र

play13:12

सपोज आ राइटिंग प माइनस

play13:15

क राइट ए परसेंटेज डी बिक इट विल गव इट

play13:19

वैल्यू सो प माइनस क बोथ विल प्रिंट लेट

play13:23

मी जस्ट यूज

play13:25

स्ल सो ना लेट मी रन दिस एंडी आउटपुट यू

play13:30

गेट सी q - p इज 3 एंड p - q इज -3 बिकॉज

play13:35

p इज पॉइंट टू फर्स्ट एलिमेंट q इज पॉइंट

play13:38

टू अ द फोर्थ एलिमेंट दैट इज इंडेक्स थ्री

play13:42

सो q इज पॉइंट टू दिस जीरो हाउ मेनी

play13:44

एलिमेंट्स बिटवीन p एंड q थ्री एलिमेंट दे

play13:47

आर थ्री एलिमेंट अपार्ट दैट इज व्हाई p -

play13:49

q इज -3 एंड q - p इज 3 राइट आई होप यू

play13:52

गोट दिस एंड नाउ इफ आई सपोज आई ऐड p आई एम

play13:58

नॉट डूइंग दिस विद आई एम डूइंग ट q

play14:03

माइनस

play14:05

ू राइट एंड

play14:08

नाउ नाउ सपोज आई वांट टू प्रिंट

play14:20

वैल्यू परसेंटेज डी एंड आई एम जस्ट

play14:23

प्रिंटिंग एट्रिक

play14:25

क राइट एंड बिफोर अपडेटिंग दिस q आल्सो आई

play14:29

एम प्रिंटिंग

play14:33

वैल्यू परसेंटेज डी एंड आई एम प्रिंटिंग

play14:36

एट्रिक क्य सो लेट्स सी व्हाट इट इज

play14:41

गिविंग

play14:44

सी वैल्यू इज फर्स्ट ऑफ ल वैल्यू इज जीरो

play14:49

स्टार क्य बिकॉज एट a ऑथ एट थर्ड इंडेक्स

play14:53

वी हैव वैल्यू जीरो एंड नाउ वी हैव मूव्ड

play14:56

दिस क्यू पॉइंटर बैक टू पोजीशन सो इट शुड

play15:00

गिव फोर न एंड टू सो वैल्यू इ नाउ फोर सो

play15:05

आई होप यू ग हाउ आर न पॉइंटर एनी इंजर

play15:10

कांस्टेंट इंजर वैल्यू स्टक्ड फ्रॉम

play15:12

पॉइंटर राइट एंड इफ आई ड यर प इ प प् 2

play15:18

राइट एंड नाउ आई एम प्रिंटिंग द डिफरेंस

play15:21

प्रिंट एफ हेयर आई एम प्रिंटिंग

play15:24

वट q माइनस प इक्टू परसेंटेज d एंड हेयर

play15:29

आई एम प्रिंटिंग q -

play15:31

p व्हाट इट शुड गिव द वैल्यू सी q इज

play15:38

पॉइंट टू फोर दिस एलिमेंट नाउ p वी हैव

play15:41

मूव्ड टू पोजीशन फॉरवर्ड सो नाउ p इज

play15:44

पॉइंट टू फर्स्ट ऑफ़ ऑल p वाज पॉइंट टू

play15:46

दिस टू फर्स्ट एलिमेंट देन नाउ p इज पॉइंट

play15:49

टू दिस वन थर्ड एलिमेंट थ्री राइट सो q इज

play15:53

पॉइंट टू दिस फोर p इज पॉइंट टू दिस

play15:56

एलिमेंट थ्री सो नाउ व्हाट q -

play15:59

शुड गिव

play16:01

सी मानव इट शुड गिव सी q माइन प इ

play16:06

माइव राइट नाउ q माइन प इ अपडेटेड वैल्यू

play16:11

इट इ गिविंग द डिफरेंस माइव राइट एंड इफ

play16:14

यू फदर मूव लाइक दिस आई एम राइटिंग q इ क

play16:20

माइनस 2 ऑलरेडी नाउ q इज पॉइंट टू दिस वन

play16:24

आई मीन दिस फोर एलिमेंट और यू कैन से

play16:27

सेकंड एलिमेंट सो इ यू ड क माइनस टू इट

play16:30

विल मूव टू पोजीशन बैकवर्ड सो वन पोजीशन

play16:34

बैकवर्ड इट विल पॉइंट टू टू वन पोजीशन मोर

play16:37

वी डोंट हैव एनीथिंग सो इट विल गिव एनी

play16:39

गार बेज वैल्यू राइट सो नाउ इफ यू

play16:42

प्रिंट प्रिंट एफ एंड नाउ इफ यू प्रिंट द

play16:46

वैल्यू च इ पॉइंटेड बाय

play16:49

दिस

play16:51

क्य सो आम प्रिंटिंग एस्टिक

play16:55

क्य सी नाउ व्ट इट विल गिव इट विल गिव आर

play16:58

बेज वैल्यू बिकॉज इट इज आउट आउट ऑफ बाउंड

play17:01

मींस इट्स बियोंड द एरे सो सी द वैल्यू

play17:04

फाइनल इट इज प्रिंटिंग

play17:06

54 बट वी डोंट हैव एनी 54 दिस एलिमेंट इन

play17:09

दिस एरी सो इट इज गिवि गिविंग एनी कार बेज

play17:11

वैल्यू राइट सो बेटर टू इंक्रीज और

play17:13

डिक्रीज दज पॉइंट्स विद इन द रेंज ऑफ दिस

play17:16

एरे टू गिव करेक्ट आउटपुट अदर वाइज इट विल

play17:20

शो अनडिफाइंड बिहेवियर और इफ इफ यू विल

play17:23

टेक लाइक टू पॉइंटर p एंड q एंड टू एरे यू

play17:25

विल टेक देन यू कैन सी p - q और q - p गिव

play17:28

सम अनडिफाइंड बिहेवियर राइट बिकॉज़ दैट इज

play17:31

ऑफ ओबवियसली नो यूज़ इफ बोथ आर पॉइंट टू

play17:33

डिफरेंट डिफरेंट एरिज देन व्हाट्स द यूज़

play17:35

ऑफ़ फाइंडिंग डिफरेंस राइट सो आई होप दैट

play17:38

ट फॉर दिस वीडियो नाउ सो इन द नेक्स्ट

play17:40

वीडियो वी विल सी हाउ टू अप्लाई

play17:42

इंक्रीमेंट एंड डिक्रिमेंट ऑपरेटर्स ऑन

play17:44

पॉइंट्स नाउ आई विल सीयू इन द नेक्स्ट

play17:45

वीडियो टिल देन बाय बाय टेक केयर

Rate This

5.0 / 5 (0 votes)

相关标签
C ProgrammingPointer ArithmeticLearning CMemory AllocationArrays in CProgramming BasicsPointer OperationsCoding TutorialC LanguageProgramming Tips
您是否需要英文摘要?