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!
Keep in mind, when using malloc on something, use free to free the allocated memory when you no longer need it.
Thank you so much. Well presented and to the point 👍
You’re very welcome, I’m glad you enjoyed it! :-)
thank you showing both ways to point to something!
You're very welcome! :-)
So well explained! Thank you
Thanks your explaining and speaking so clear I can understand easily
You're welcome Abdulsamet! :-)
Nice explanation
I’m glad you enjoyed the explanation! :-)
Thanks man You really made my day
if im using an arrow how do i scan into those varibale?
Magic, you need to call Harry Potter. I'm actually wondering the same thing.
Thanks for supplying the code! That's awesome
You're welcome Lex! :-D
Love this!
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
It would do it all the time, even when you don’t want it to?
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
Very well explained. Thanks
You’re welcome Ulas, I’m glad you enjoyed the explanation! :-)
thanks man. I finally get it 😅
which IDE are you using?
Thanks for these videos i hope i can pass my exams.
You're welcome Aaron, and good luck on your exams! :-)
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().
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.
@@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...
@@marbles5590 I suppose you are using c++ compiler . You need to change your main.cpp to main.c
@@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 😅
hello from Brasil.
thanks!
You're welcome! :-) And hello from Canada!
clear in very helpful
Awesome, I’m glad to hear that! :-)
what text editor r u using
In this video I am using Xcode on a Mac. 🙂
Thank you!
You’re welcome Ion! :-)
when we use char data types for this, it doesnt work.
Thank you sir ...
You're welcome! :-)
what text editor u r using
X code on mac
You are godlike.
Aww haha thank you very much for the support. :-)
👍
Thanks! :-)
Really nice explanation, thanks!
You’re welcome, I’m glad you enjoyed the explanation! :-)