Arrow Operator For Pointers To Structs | C Programming Tutorial

Sdílet
Vložit
  • čas přidán 12. 11. 2021
  • How to use the arrow operator in C to access the member variables of a struct when we have a pointer to the struct. Source code: github.com/portfoliocourses/c.... Check out www.portfoliocourses.com to build a portfolio that will impress employers!
  • Jak na to + styl

Komentáře • 49

  • @CoolModderJaydonX
    @CoolModderJaydonX Před měsícem +4

    Keep in mind, when using malloc on something, use free to free the allocated memory when you no longer need it.

  • @thesuperiorman8342
    @thesuperiorman8342 Před rokem +18

    Thank you so much. Well presented and to the point 👍

  • @iwannapressit6886
    @iwannapressit6886 Před rokem +7

    thank you showing both ways to point to something!

  • @pixelgamesSARLS
    @pixelgamesSARLS Před 3 měsíci

    So well explained! Thank you

  • @LexElls
    @LexElls Před 2 lety

    Thanks for supplying the code! That's awesome

  • @abdulsametaybaz3321
    @abdulsametaybaz3321 Před rokem +1

    Thanks your explaining and speaking so clear I can understand easily

  • @michasmykowski5753
    @michasmykowski5753 Před 3 měsíci

    Thanks man You really made my day

  • @zattirizortzort486
    @zattirizortzort486 Před rokem

    Very well explained. Thanks

    • @PortfolioCourses
      @PortfolioCourses  Před rokem +1

      You’re welcome Ulas, I’m glad you enjoyed the explanation! :-)

  • @avixx
    @avixx Před 4 měsíci

    Love this!

  • @mr.luxxyandreneo5168
    @mr.luxxyandreneo5168 Před rokem +1

    Nice explanation

  • @user-gx9wl7lm7k
    @user-gx9wl7lm7k Před 5 měsíci

    thanks man. I finally get it 😅

  • @SameerAhmed-wf8yf
    @SameerAhmed-wf8yf Před 3 měsíci

    which IDE are you using?

  • @radomeditv
    @radomeditv Před rokem

    clear in very helpful

  • @ionguzun3952
    @ionguzun3952 Před 2 lety

    Thank you!

  • @hicg
    @hicg Před rokem

    hello from Brasil.
    thanks!

  • @awekeningbro1207
    @awekeningbro1207 Před 6 měsíci

    when we use char data types for this, it doesnt work.

  • @elisha502
    @elisha502 Před rokem +3

    if im using an arrow how do i scan into those varibale?

    • @ratdude010
      @ratdude010 Před 6 měsíci

      Magic, you need to call Harry Potter. I'm actually wondering the same thing.

  • @aravinthr607
    @aravinthr607 Před rokem

    Thank you sir ...

  • @marbles5590
    @marbles5590 Před rokem +2

    Thank you for this video... although I had problems in my code. It says 'cannot convert int* to Point'. I don't have any problems using the arrow operator and such, only this (*p3), p3-> thing after dynamically allocating using malloc().

    • @PortfolioCourses
      @PortfolioCourses  Před rokem

      You're welcome! :-) And I'm not sure why that would be without seeing the code, can you maybe post your code in a comment here so I can look at it? I've posted the code in this video here: github.com/portfoliocourses/c-example-code/blob/main/arrow_operator.c.

    • @marbles5590
      @marbles5590 Před rokem

      @@PortfolioCourses hello, I used another IDE and the code works. My code is just the same as yours. Maybe this error has something to do with my settings...

    • @Quasarsoft
      @Quasarsoft Před rokem

      ​@@marbles5590 I suppose you are using c++ compiler . You need to change your main.cpp to main.c

    • @marbles5590
      @marbles5590 Před rokem

      @@Quasarsoft ty for that but i have already solved the prob months ago. Still there are times i get used to using the devc++ compiler and forgot to change it to .c 😅

  • @mementomori7160
    @mementomori7160 Před 5 měsíci +2

    I know it's old but, why can't the compiler jsut dereference the pointer first? Do you know if there is a reson for that? That way they wouldn't need a completely new operator to exist

    • @ladyville3
      @ladyville3 Před 5 měsíci +1

      It would do it all the time, even when you don’t want it to?

    • @jeremykhoo5127
      @jeremykhoo5127 Před 3 měsíci +1

      Sometimes you want to change the address of the pointer and not the value
      You have an address to a John's house. Set to Mary
      A postman subroutine has a pointers to "delivery for" it is set at adress: John's house
      Person: Marry
      So it means you will go to John's house and deliver the package to Mary who lives there
      If you always dereference that means you can only deliver to the people in John's house (Mary and John). You cannot deliver to anyone in Clements' house
      ie you can only change the value, you cannot change the address

  • @iuseyoutubealot
    @iuseyoutubealot Před rokem +1

    what text editor r u using

  • @erennkose
    @erennkose Před rokem

    Thanks for these videos i hope i can pass my exams.

  • @joaco.
    @joaco. Před rokem

    You are godlike.

  • @hakant.5806
    @hakant.5806 Před 6 měsíci

    👍

  • @dimpe5038
    @dimpe5038 Před rokem

    Really nice explanation, thanks!

    • @PortfolioCourses
      @PortfolioCourses  Před rokem +1

      You’re welcome, I’m glad you enjoyed the explanation! :-)