Arrow Operator For Pointers To Structs | C Programming Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ส.ค. 2024
  • 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/por.... Check out www.portfolioc... to build a portfolio that will impress employers!

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

  • @CoolModderJaydonX
    @CoolModderJaydonX 3 หลายเดือนก่อน +6

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

  • @thesuperiorman8342
    @thesuperiorman8342 ปีที่แล้ว +19

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

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

      You’re very welcome, I’m glad you enjoyed it! :-)

  • @iwannapressit6886
    @iwannapressit6886 ปีที่แล้ว +8

    thank you showing both ways to point to something!

  • @pixelgamesSARLS
    @pixelgamesSARLS 4 หลายเดือนก่อน +1

    So well explained! Thank you

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

    Thanks your explaining and speaking so clear I can understand easily

  • @mr.luxxyandreneo5168
    @mr.luxxyandreneo5168 ปีที่แล้ว +1

    Nice explanation

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

      I’m glad you enjoyed the explanation! :-)

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

    Thanks man You really made my day

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

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

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

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

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

    Thanks for supplying the code! That's awesome

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

    Love this!

  • @mementomori7160
    @mementomori7160 6 หลายเดือนก่อน +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 6 หลายเดือนก่อน +1

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

    • @jeremykhoo5127
      @jeremykhoo5127 4 หลายเดือนก่อน +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

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

    Very well explained. Thanks

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

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

  • @user-gx9wl7lm7k
    @user-gx9wl7lm7k 6 หลายเดือนก่อน

    thanks man. I finally get it 😅

  • @SameerAhmed-wf8yf
    @SameerAhmed-wf8yf 4 หลายเดือนก่อน

    which IDE are you using?

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

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

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

      You're welcome Aaron, and good luck on your exams! :-)

  • @marbles5590
    @marbles5590 ปีที่แล้ว +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  ปีที่แล้ว

      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 ปีที่แล้ว

      @@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 ปีที่แล้ว

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

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

      @@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 😅

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

    hello from Brasil.
    thanks!

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

      You're welcome! :-) And hello from Canada!

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

    clear in very helpful

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

    what text editor r u using

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

      In this video I am using Xcode on a Mac. 🙂

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

    Thank you!

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

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

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

    Thank you sir ...

  • @pirasannanmusicals
    @pirasannanmusicals 14 วันที่ผ่านมา

    what text editor u r using

  • @joaco.
    @joaco. ปีที่แล้ว

    You are godlike.

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

      Aww haha thank you very much for the support. :-)

  • @hakant.5806
    @hakant.5806 7 หลายเดือนก่อน

    👍

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

    Really nice explanation, thanks!

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

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