Understanding the Wild Pointers

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ก.ย. 2024
  • Data Structures: Understanding the Wild Pointers
    Topics discussed:
    1) What is a Wild Pointer?
    2) An example Wild Pointer.
    3) How to avoid the Wild Pointers?
    C Programming Lectures: goo.gl/7Eh2SS
    Follow Neso Academy on Instagram: @nesoacademy(bit.ly/2XP63OE)
    Follow me on Instagram: @jaspreetedu(bit.ly/2YX26E5)
    Contribute: www.nesoacademy...
    Memberships: bit.ly/2U7YSPI
    Books: www.nesoacademy...
    Website ► www.nesoacademy...
    Forum ► forum.nesoacade...
    Facebook ► goo.gl/Nt0PmB
    Twitter ► / nesoacademy
    Music:
    Axol x Alex Skrindo - You [NCS Release]
    #DataStructuresByNeso #DataStructures #WildPointer #Pointer

ความคิดเห็น • 41

  • @vishugahlot397
    @vishugahlot397 3 ปีที่แล้ว +7

    in the last example
    after free(p);
    p will become the dangling pointer or not ?
    according to me it will .

    • @aryanrasaily8252
      @aryanrasaily8252 2 ปีที่แล้ว +4

      yes it will

    • @raghuvadla4189
      @raghuvadla4189 ปีที่แล้ว

      Yes , after de allocating the memory we need to make sure to re initialize the pointer.

  • @aryanrasaily8252
    @aryanrasaily8252 2 ปีที่แล้ว +7

    instead of initializing wild pointers with (1) address of memory and (2) using malloc which may result in dangling pointer if null not used
    why not direct initialize it with null as that's gonna be the simplest step to avoid wild pointers.

  • @gyanendramohanpatel823
    @gyanendramohanpatel823 4 ปีที่แล้ว +4

    sir in the second case of avoid . is ptr is not behaving line dangling pointer . we did not need to reinitialize with NULL .
    please reply.

    • @oggy107
      @oggy107 3 ปีที่แล้ว +2

      no... the memory which is explicitly allocated is existing memory... well this is just a guess

  • @monicabattacharya6416
    @monicabattacharya6416 2 ปีที่แล้ว +4

    Dear Neso Academy , Please reply 🙏🏼🙏🏼🙏🏼🙏🏼🙏🏼🙏🏼🙏🏼🙏🏼🙏🏼🙏🏼🙏🏼🙏🏼🙏🏼🙏🏼🙏🏼. what is the difference between datastructures and advanced datastructures?

    • @VishnuIITMadras96
      @VishnuIITMadras96 ปีที่แล้ว +1

      Data structures are normal things You already knew, Advanced data structures are used to create efficient and effective software design

  • @sagarsingh-zy3ws
    @sagarsingh-zy3ws 4 ปีที่แล้ว +1

    Thanx for great videos can u plzz guide me.. more for my successfully carrier...

  • @urvashidhangar1016
    @urvashidhangar1016 4 ปีที่แล้ว +2

    Pls try to upload data structures full course asap

  • @prajwalh8823
    @prajwalh8823 ปีที่แล้ว +1

    In second example after free(p) the ptr will now does not point anywhere so is it now dangling pointer since we have not reinitilized again?

    • @art_shade
      @art_shade ปีที่แล้ว +2

      Sure, but the program ended there right after the `free()` call, and are you sure you want to process the process local data further without any meaning in the end since the program will just stop executing? More to that, it's worth to mention that `int *p = NULL;` is also an option which does not allocate any memory by default, in contrast of that `malloc`, and that would allow for less memory resource requirements in bigger projects. I am curious why the Author of the video did not mention that considering the previous videos in the subject.

    • @prajwalh8823
      @prajwalh8823 ปีที่แล้ว

      @@art_shade 👍

  • @prajwalgaidhani9906
    @prajwalgaidhani9906 4 ปีที่แล้ว +2

    in the second point (explicitly allocate the memory )
    is p dangling pointer ?

    • @firstnamelastname3532
      @firstnamelastname3532 3 ปีที่แล้ว +1

      Stuck on the date palm fell from the sky!

    • @oggy107
      @oggy107 3 ปีที่แล้ว +1

      no i guess because the memory allocated explicitly is existing.

  • @debajyotighosh370
    @debajyotighosh370 4 ปีที่แล้ว +5

    we can also assign the pointer to null

  • @ahmedkilany0
    @ahmedkilany0 4 ปีที่แล้ว +4

    Please download explain for Dynamic memory allocation "malloc and calloc"

  • @nishyu9101
    @nishyu9101 2 ปีที่แล้ว +1

    Awesome concepts explained

  • @kingdey9136
    @kingdey9136 4 ปีที่แล้ว +11

    sir we want such tutorials on python too...

  • @friendsfandom
    @friendsfandom 3 ปีที่แล้ว +2

    Bro u told uninitialized comes under null pointer

  • @HelloWorld40408
    @HelloWorld40408 ปีที่แล้ว

    Thank you sir

  • @sallaklamhayyen9876
    @sallaklamhayyen9876 2 ปีที่แล้ว

    Top thank you so much

  • @compilerrun5516
    @compilerrun5516 3 ปีที่แล้ว +2

    Can't we avoid wild pointers by NULL

    • @oggy107
      @oggy107 3 ปีที่แล้ว +1

      we can

  • @dhairyapatel3880
    @dhairyapatel3880 6 หลายเดือนก่อน +1

    Or you could also avoid a wild pointer by initializing it with NULL.

  • @shadespitterr3366
    @shadespitterr3366 หลายเดือนก่อน

    Why not simply assigning NULL to the pointers to avoid it being WILD POINTER?

  • @garykapoor5122
    @garykapoor5122 4 ปีที่แล้ว +1

    These are very short videos, please try to upload more videos in one day

  • @narendrajayram1317
    @narendrajayram1317 3 ปีที่แล้ว

    last example is still a problem as pointer 'p' is still pointing to an unallocated memory address. Seems simply assigning NULL to the pointer 'p' will solve the problem

    • @oggy107
      @oggy107 3 ปีที่แล้ว +1

      no... p is pointing to a reserved a memory segment and it will not be wild anymore. But as you said we can also assign null to p

  • @itsritika3561
    @itsritika3561 4 ปีที่แล้ว

    👍👍

  • @sastaengineer3038
    @sastaengineer3038 ปีที่แล้ว

    Mere teacher oops ke pura Apna handwritten notes bheje hai.....
    Guess what yhi Se likhe hai pura...
    #Enginnerling

  • @AutoFirePad
    @AutoFirePad 4 ปีที่แล้ว +3

    Why the F are you casting malloc in C!

    • @jacobgsutton
      @jacobgsutton 4 ปีที่แล้ว +2

      malloc returns void pointer so you have to cast it to int pointer type if you set it to int pointer

    • @mgx9383
      @mgx9383 4 ปีที่แล้ว +3

      @@jacobgsutton No, you don't. It is unnecessary. In C conversion is done automatically (unlike in C++).
      In my opinion, the best way to do it is probably like this:
      type* p = malloc(sizeof(*p));
      Above, you have to care about type only in one place.
      Below, you have three places that specify the type, and must be kept in mind:
      type* p = (type*)malloc(sizeof(type));

    • @AutoFirePad
      @AutoFirePad 4 ปีที่แล้ว +1

      mgx Exactly, that's the best solution in my experience.

    • @sagarbisht9649
      @sagarbisht9649 3 ปีที่แล้ว

      considered a good practice

    • @hetaeramancer
      @hetaeramancer 3 ปีที่แล้ว

      @@sagarbisht9649 what is?