Pointers as function arguments - call by reference
Vložit
- čas přidán 15. 02. 2013
- See complete series on pointers here • Pointers in C/C++
In this lesson, we will see one of the use cases of pointer variables which is using them as argument to functions. We will describe the concept of call by value and call by reference.
Please see previous lessons here-
• Pointers in C/C++
For practice problems and more, visit: www.mycodeschool.com
Like us on Facebook: / mycodeschool
Follow us on twitter: / mycodeschool
These four sections are created for each program. It will not be safe for programs to enter each other's memory. So, OS allocates memory for each application. The size of stack, text/code segment and global section is decided at compile time. Heap can grow during run time.
P.S: There are no stupid questions, there are only stupid answers. So, it's me who may be wrong. :)
If we add return a in increment fn then it should return 11 to main function?
Sugam Kumar nope
@@sugamkumar8266 Yes, also you have to change the increment return type function from void to int , and in main function you have to catch the returned a value from incremental function. Thats also work !!
@@akhilgupta3664 👍👍
How are you not a professor? Your better at explaining things than some of the more pronounced professors at my school. Thank you very much, this is helping me prepare for CS1
Thanks Jai ! I do not have the heavy degrees to become a professor. :P
He is the best that I've seen yet. Using Feynman learning techniques combined with the videos presented makes learning enjoyable. One can see how rote memorization fails to develop comprehension for abstract concepts.
@@ajaykarthik4520 Unfortunately, the creator of mycodeschool passed away a few years ago. He was known by pseudonym "humblefool". You can search about him.
@@monikaparmar2061 Oh so sad..... Thank you for replying
@@mycodeschool hey, who taught this particular playlist, was it the programmer known as the "HUMBLEFOOL" who died?
I could not have asked for a better explanation, thank you.
Who needs code with Harry ... You are the best ❤️
Wow, literally had problems undersatnding pointers for like 8 months. Watching your videos on the topic really open my eyes. You deserve an award.
A perfect explanation to pointers and how to use. Even the video is 8 years old it still teaches valuable information, well done.
Literally blown my mind with some things I've been struggling to understand for a couple of years now...thank you so much!
the amount of new things i learn from you instead of my school. i wish my school tuition goes to you
I'm watching the whole pointer playlist and I must say that these are the best I could find on the whole internet...
We are simultaneously learning about assembly (or low level stuff) which is awesome! Everything makes sense now and as I watch more videos, the clarification increases.
9 years old video, still relevant to this day, thanks for making the concept of pointers crystal clear, god bless u, good man!
you just explained functions, pointers, variables and the stack so clearly and visually in one video. extremely helpful - i could not thank you enough!
*My takeaways:*
1. Memory: heap, stack, static/global and code 4:21
2. *a* in the *Incremental* function is deleted before the program calling *printf* 8:20
3. Call by value 10:10
4. Call by pointer/reference 11:09
I'm Albert ;(.
Or rather, I was until I saw your videos :D.
dISGUSTING!
Isaac Fujimoto ??
two years of coding and its the first time to understand this part
beautiful work can you make a series on oop
You have solved what I have been confused with over the years, thanks for your contribution and efforts on great teaching! You are the best lecturer I have met so far and you should become a professional professor!
The best video on pointers and call by reference, you employed well enough approaches to make it incredibly easy to understand. Take a bow!
I am reiterating all the compliments you received from others before me! You make a fantastic teacher!! Totally love your explanation! They make for a crystal clear understanding of these concepts which are otherwise very confusing! A big thank you!
You rock!!! The expression after watching this tutorial will be:
" Right in the money baby"
Thanks for the perfect explanation.
aburridohp Thanks :)
I cannot thank you enough, this cleared up so many days of confusion.. Really appreciate the effort you've put into these videos. Very valuable.
best series of explanation on pointers ever on this earth!!
Do you mean, we should put the tutorial number? Please see the description for complete playlist on pointers. We are still adding tutorials in this playlist.
For the first time I am loving pointers!! Thank u soo much.. you have taught me what the books , teachers and trainers could never teach me
Even the recent big CZcamsrs cant match your teaching style. You are the best professor! Thank you so much :)
Best explanation of pointers on CZcams so far. Thanks a lot.
This is one of the most simplest and clearest explanation i have ever seen on the pointers in all of history. Very impressive 😃😃
I went through a lot of youtube video lectures but finally found your playlist, and it's the best of all, your teaching skills are amazing, really appreciate your efforts.
Thank you for taking the time to make these. I admit that at first I had a little trouble with your accent, but I've gotten used to it now. The information is great! Thanks!
The subtitles are incredibly helpful. They make your videos even better! Thanks :)
this is the most useful 10 mins that I've spent in trying to understand pointers !! such an in depth explanation .. Always wonder why my college teachers DON'T teach like u ppl ..Think i have to recommend these to them first..Thank you so much for sharing ur knowledge !! U R AWSM !!
5 alberts disliked ..
however , you rock by these videos , great explanation , and the most importan thing is that you explain such deep toics soo easily , thumbs up for the efforts
i didn't get the reference behind Albert? whats that mate?
Wow. Incredible. I know you don't need any more praise, but this is amazing! Thank you.
Oooh man!!! Are U a Standfor's or MIT's or Harvard's Proffesor??? Your teching method is excellent, you explain very clear. I was crashing my brain trying to understand real uses for pointers and how they work in memory's computers. I got all of this pointers stuff clear right now thanks to you man. greetings from Mexico.
He Studied at Indian Institute of Information Technology!
The way you are explaining is absolutely brilliant. Even our professors won't even know the names of what you are telling..🙏🙏
Shame on the 52 people who disliked. Such great content and explanation deserves credit. Good work Animesh.
It is so sad and so unfortunate that I found your lessons yesterday.
They are pure jewel. Thank you...
Minor correction: your example is strictly speaking "call by pointer", not "call by reference." Call by reference would have the signature: "void increment(int &a)" and would be called using "increment(a);". Otherwise, great explanation - hope you continue sharing your teaching talent. I really appreciate your videos!
@Mekonen S He's partially wrong. His example didn't work because that is C++, not C.
Nevertheless, he was correct when he said that the example in the video is not passing by reference. Strictly speaking, that is also pass-by-value - it's just that you're passing the pointer by value.
C doesn't pass by reference, only by value. I know this can be really confusing, and newer definitions of pass-by-reference and pass-by-value complicated things a little bit, so I recommend reading the following:
- stackoverflow.com/questions/373419/whats-the-difference-between-passing-by-reference-vs-passing-by-value
- stackoverflow.com/questions/2229498/passing-by-reference-in-c
- www.quora.com/What-are-the-advantages-of-using-references-over-pointers (see Sergey's answer)
Can you elaborate more please
@@marcelalves6196 Thanks very much. This is really helpful.
I cannot explain how much I love you. Thank you so much! Your explanations are the best.
I learned about pointers from this channel a year ago and i haven't revised still I didn't forgot anything these are really great videos which gives clear image of everything. thank you animesh sir I am waiting for your videos on algorithms as well and ya we miss you harsha sir.
Excellent Teacher. I totally admire you. Thanks for this amazing material!
That's the best I've ever understood call by reference in 4 years of learning c++
Your precise explanations are putting collage professors to shame! Kudos to you
this how the great teacher is ,, thanks alot
sir, u are simply amazing....great explaination,,,brilliant simplification of concepts using examples,,,great quality video and audio,,,mostly to the point ,,,keep up the gud work,,,U ROK
Trying to transform from an Albert to a programmer.Thank you so much.cleared the concept
Tough topics get easy: One of the best video lecture series I ever had
Rest in peace brother, your legacy lives after you :-(
I am sry, may I know what's going on with this great professor?
@@rickyruan6230 From what I can gather he died after being struck by a car. I am not sure how long ago but I think it has been maybe 4 or so years. Tributes to this great teacher are all over the comments. Watching these videos for me is bittersweet, I would love to personally thank him for how he has helped my computer science understanding grow.
Omg! my heart breaks! , God! Rest in peace such a great teacher 😢❤
I have several books on C, including those that are top rated on amazon.
These videos beat them all.
Exceptionally useful. Thank You.
*Most of us were unclear of the fact what we actually want which was cleared after watching your MASTERPIECE.*
I have never seen someone explain the concept of call by reference and value through stack(which is how it works in real life). kudos!!
This is the first time I understood what exactly call by reference is .... thank you so much.
Subscribed You
Very clear and extensive explanation. Thank you for your work.
I don't really comment that much, but this is pure perfection!!! RIP Harsha
The best call by reference explanation indeed ... the memory showing method is very helpful
thanks!
You are the best teacher ive ever met...
Thanks to you, now i understand concept of pointer, call by reference and call by value
You are awesome man !!! best tutorial of pointer ever , thank you so much for making it !!
you are really great.... thank you very much....the way you explain is really awesome....faculties from renowned institute should learn from you
These are very helpful! Thank you so much!
the best channel on CZcams for learning
Thank you...i have written it as you explained it..Great lesson!
Bhaiiiiiiiii great piece of knowledge
Amazing Explaination..............like a c in sea...............Thanks a lot.........fan of u
DUDE, GREAT JOb! omg i regret not watching this video 3 years ago when i was in college..... despite the fact it was created in 2013 but still >.
You sir are AWESOME! Why cannot my professors explain it like this? They just over-complicate it took sophisticated!
This is the best explanation I got, Thank you.
oh,,,, thank you very much ! very clear explanation. the best explanation i have ever seen ... good luck and keep up!
Hi Gaukhar,
Virtual address space in a typical architecture should probably be represented like what you are saying. The intent here was to show that there are these logical segments in applications memory with specific roles. How they are implemented is a thing of architecture and can vary with machine, OS and compiler. For example, whether stack will grow from low address to high or high to low will also depend upon architecture.
Thank you so much. You did a wonderful job explaining this.
thank you, very informative and helped me understand a lot of important things.
@mycodeschool which ide or compiler of which version you are using bro please give complete details . thanks in advance you are the best .
Superb video!!! Loved it. Beautifully explained👍👍
Thank u very much ! With ur video it's easy to understand difficult things!
wow i cant believve i am still going into further depth......nice tutoring mannn......
i finally understand why indians are so good at programming, because their teachers teaching skills are far more better than our's.
I like Albert's adventures in programming :)
thank u very much sir for the series! The best explanation.. Awesome...u made my concepts damn clear.. :)
This is best...I think, even paid tutorials are not as good as this......Thanks a lot man....:)
Awesome explanation to a difficult topic.. Thank you sir.
you are better than 4 of my teacher "stacked" together (got the little joke i put here?) . Great job man, keep the good work, You are like me, you explain it Simple and logial, step by step. Your videos till this, about one hour, explained better than my teachers tried in 10 hours.... Pretty awesome, i guess:)
very very helpful and ur explanation method is unbelivable
thanks for this beautiful video , I m going into deep day by day!!!!
At least someone can explain it so I can understand.... Thanks bro!
very clear explanation sir..thank you soo much
I love u brother
Very awesome explanations. Thank you.
" Albert writes a simple code "
That's simple code? damn Albert!
you still haven't seen anything
bro im doing pg dac course through cdac chennai and i find your lectures very usefull
Ultimate..ur explaination is awesome
Ty Sir,U really taught very well,awesome explanation
+mycodeschool Awesome Tutorial and Explanation. But please take care of Audio output(good if its bit louder) if it was rectified this will be the best tutorial. Thanks man....
m preparing for my exams.....that was a lots of help.....thanks
Great stuff man!!
hats off!!!!
THANK YOU! exactly what I was looking for
Thanks sir .
You are the best teacher in the world.
thaks!! your videos are just too good!! want more about java and adroid!! :)
U explain really well! Thanks a lot :)
Stunning tutorial!
best explanation to understand pointers!!
Thanks! This is incredible! :)
Thank you very much for your explanation! You rock!