Dereferencing in C

Поделиться
HTML-код
  • Опубликовано: 3 сен 2019
  • Dereferencing can be done using either the dereference operator (*) or the array subscript operator ([]). In this video we'll talk about a few quirks regarding these two operators.
    Check out our Discord server: / discord

Комментарии • 32

  • @sepgh2216
    @sepgh2216 5 месяцев назад

    As a person who learn programming from top to bottom (I started by Java and was never told about memory) and is new to C this just blew my mind! Amazing explanation! Now everything is starting to make deeper sense.

  • @davidjiang7929
    @davidjiang7929 3 года назад +3

    I really like your explanations. Thank you!

  • @sempercrescere6274
    @sempercrescere6274 Год назад

    Great explanation, thank you so much, please continue your great work!

  • @SammanMahmoud
    @SammanMahmoud 3 года назад +1

    Thank you very much for your wonderful videos.... please do not stop :)

  • @doragonmeido
    @doragonmeido 2 года назад +1

    ive always been confused about int* p and int *p
    and thank you for showing the weird stuffs with array
    had my mind blown again

  • @ciprianparaschiv7591
    @ciprianparaschiv7591 2 месяца назад

    Great video, I like your style.

  • @mateuspereira214
    @mateuspereira214 Год назад

    Thank you sir, that's been really helpful!

  • @smwx4
    @smwx4 Год назад

    Yea, this is a great explanation, you did a excelent work

  • @navidnouri151
    @navidnouri151 2 года назад

    excellent!Thank you!

  • @krtirtho
    @krtirtho 2 месяца назад

    Impressive!

  • @shaharrefaelshoshany9442
    @shaharrefaelshoshany9442 2 года назад

    YOU ARE AMAZING :))

  • @mahadifamgate2686
    @mahadifamgate2686 2 года назад

    GOOD VIDEO ,,, THANK YOU.

  • @ib1664
    @ib1664 4 года назад +2

    Excellent work on these vids can you please discuss pointers to multidimensional arrays and there relationships to double pointers etc, as well using single loops to iterate through multidimensional arrays. Thanks

    • @CodeVault
      @CodeVault  4 года назад +1

      I'll make a video on multidimensional arrays next week (as there are multiple ways to go about it).

  • @parisa9374
    @parisa9374 2 года назад

    Thank you very much for making these tremendous informative sessions available to everyone.
    One question? How did you set up your VScode to pop up this "Exception Thrown" window for errors? (@4:24)

    • @CodeVault
      @CodeVault  2 года назад +1

      What I am using in this video is actually Visual Studio 2019 Community and it's a completely different IDE from Visual Studio Code. It has this expection pop-up function built-in

    • @parisa9374
      @parisa9374 Год назад

      @@CodeVault I got it. Thanks.

  • @TrebleWing
    @TrebleWing 2 года назад

    Why would they make the symbol (*) so incredibly complicated? It has two different meanings, and both are in the context of pointers. That is just asking to be easily conflated with.
    Thanks for explaining though. That helped

  • @flywet
    @flywet 3 года назад

    As you say at 2:55 , i was confused. What's different when we use int* p and int *p? Btw great tutorial sir

    • @CodeVault
      @CodeVault  3 года назад +3

      int* p and int *p are exactly the same thing. But, if you do:
      int* p = &a;
      *p = 5;
      The asterisk from "int*" denotes that p is a pointer of type int. But that asterisk from down below denotes a dereference. That's what I meant at that point in the video.

    • @flywet
      @flywet 3 года назад

      @@CodeVault Great, you are very good teacher. That asterisk actually confused me. Now i understand the asterisk use for pointer assignment & dereference are not the same. Thanks

  • @pawanthanay
    @pawanthanay 3 года назад

    please explain about char* what does that mean?

    • @CodeVault
      @CodeVault  3 года назад

      It's a pointer to character and, depending on the context, it could represent a string.

  • @saybrowt
    @saybrowt 6 месяцев назад

    I am curious why it is *(arr +1) instead of *(arr + 1 * sizeof(int))

    • @CodeVault
      @CodeVault  4 месяца назад +1

      Because all operations to pointers are automatically multiplied by the sizeof the data the pointer is pointing to. So:
      arr + 1 is actually arr + 1 * sizeof(int) inside the compiled code

    • @saybrowt
      @saybrowt 4 месяца назад

      ​​@@CodeVault Thank you so much for your clarification and further explanation. To be honest I did not expect a reply on such an old video and least of all from the creator himself, you're awesome for that. What I'm taking away from this is that what I wrote in my original comment is 1) Is valid and correct C code (correct being would work the way as described in the context of the video) and 2) Is what actually is hapenning 'under the hood'

  • @triantafullenia6873
    @triantafullenia6873 3 года назад

    what if we had:
    int * p = a?
    Is it legall ? If yes what does it mean?

    • @CodeVault
      @CodeVault  3 года назад +1

      It means you're going to get an error the second you dereference that pointer.
      int* p = a;
      This makes p point to whatever is at address 16. But since address 16 is something you don't own and is probably system reserved you'll get a crash.

    • @triantafullenia6873
      @triantafullenia6873 3 года назад

      @@CodeVault OK got it! Thank you very much

  • @realdragon
    @realdragon 2 года назад

    Now I just want in code to write out of nowhere something like 1[arr] to confuse people

    • @CodeVault
      @CodeVault  2 года назад

      That would be evil :D

  • @RacecarJ0hnny
    @RacecarJ0hnny Год назад

    haha you are kind of cute