Pointers as function arguments - call by reference

Sdílet
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

Komentáře • 348

  • @mycodeschool
    @mycodeschool  Před 11 lety +38

    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. :)

    • @sugamkumar8266
      @sugamkumar8266 Před 4 lety +1

      If we add return a in increment fn then it should return 11 to main function?

    • @kensei4237
      @kensei4237 Před 3 lety

      Sugam Kumar nope

    • @akhilgupta3664
      @akhilgupta3664 Před 3 lety +2

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

    • @sugamkumar8266
      @sugamkumar8266 Před 3 lety +1

      @@akhilgupta3664 👍👍

  • @jaifer8
    @jaifer8 Před 10 lety +234

    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

    • @mycodeschool
      @mycodeschool  Před 10 lety +135

      Thanks Jai ! I do not have the heavy degrees to become a professor. :P

    • @johnathanpatrick3593
      @johnathanpatrick3593 Před 6 lety +16

      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.

    • @monikaparmar2061
      @monikaparmar2061 Před 4 lety

      @@ajaykarthik4520 Unfortunately, the creator of mycodeschool passed away a few years ago. He was known by pseudonym "humblefool". You can search about him.

    • @ajaykarthik4520
      @ajaykarthik4520 Před 4 lety

      @@monikaparmar2061 Oh so sad..... Thank you for replying

    • @utkarshaggarwal1631
      @utkarshaggarwal1631 Před 4 lety

      @@mycodeschool hey, who taught this particular playlist, was it the programmer known as the "HUMBLEFOOL" who died?

  • @atanatirosgiliat954
    @atanatirosgiliat954 Před 10 lety +33

    I could not have asked for a better explanation, thank you.

  • @sahil1053
    @sahil1053 Před 3 lety +2

    Who needs code with Harry ... You are the best ❤️

  • @abuahchukwuedo6565
    @abuahchukwuedo6565 Před 8 lety +6

    Wow, literally had problems undersatnding pointers for like 8 months. Watching your videos on the topic really open my eyes. You deserve an award.

  • @gultekinbutun7910
    @gultekinbutun7910 Před 2 lety +8

    A perfect explanation to pointers and how to use. Even the video is 8 years old it still teaches valuable information, well done.

  • @jwj410
    @jwj410 Před 7 lety +32

    Literally blown my mind with some things I've been struggling to understand for a couple of years now...thank you so much!

  • @Donotmicrowavee
    @Donotmicrowavee Před 4 lety +5

    the amount of new things i learn from you instead of my school. i wish my school tuition goes to you

  • @bayram00
    @bayram00 Před 3 lety +3

    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.

  • @stardust857
    @stardust857 Před rokem +2

    9 years old video, still relevant to this day, thanks for making the concept of pointers crystal clear, god bless u, good man!

  • @CherryMarz
    @CherryMarz Před 6 lety +1

    you just explained functions, pointers, variables and the stack so clearly and visually in one video. extremely helpful - i could not thank you enough!

  • @leixun
    @leixun Před 4 lety +16

    *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

  • @kevinjohansson3923
    @kevinjohansson3923 Před 9 lety +220

    I'm Albert ;(.
    Or rather, I was until I saw your videos :D.

  • @georgenabil2348
    @georgenabil2348 Před 5 lety +8

    two years of coding and its the first time to understand this part
    beautiful work can you make a series on oop

  • @aw7628
    @aw7628 Před 8 lety +2

    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!

  • @mukundmadhusudanatre4368

    The best video on pointers and call by reference, you employed well enough approaches to make it incredibly easy to understand. Take a bow!

  • @akshathakini157
    @akshathakini157 Před 7 lety

    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!

  • @aburridohp
    @aburridohp Před 9 lety +25

    You rock!!! The expression after watching this tutorial will be:
    " Right in the money baby"
    Thanks for the perfect explanation.

  • @diahidvegi8536
    @diahidvegi8536 Před 2 měsíci

    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.

  • @supreethuilgol1967
    @supreethuilgol1967 Před 7 lety +2

    best series of explanation on pointers ever on this earth!!

  • @mycodeschool
    @mycodeschool  Před 11 lety +1

    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.

  • @debosmitadas1488
    @debosmitadas1488 Před 6 lety +1

    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

  • @user-uu5xd7mb8i
    @user-uu5xd7mb8i Před 11 měsíci

    Even the recent big CZcamsrs cant match your teaching style. You are the best professor! Thank you so much :)

  • @shreedharhegde7906
    @shreedharhegde7906 Před 5 lety

    Best explanation of pointers on CZcams so far. Thanks a lot.

  • @PremSai14
    @PremSai14 Před 5 lety

    This is one of the most simplest and clearest explanation i have ever seen on the pointers in all of history. Very impressive 😃😃

  • @arnabsadhukhan
    @arnabsadhukhan Před 11 měsíci

    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.

  • @Backstabbio
    @Backstabbio Před 10 lety

    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!

  • @cookiesandcode2860
    @cookiesandcode2860 Před 7 lety

    The subtitles are incredibly helpful. They make your videos even better! Thanks :)

  • @masterchef8671
    @masterchef8671 Před 8 lety

    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 !!

  • @ayush7805
    @ayush7805 Před 7 lety +16

    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

    • @Opacity5
      @Opacity5 Před 6 lety

      i didn't get the reference behind Albert? whats that mate?

  • @smashueatu
    @smashueatu Před 9 lety +2

    Wow. Incredible. I know you don't need any more praise, but this is amazing! Thank you.

  • @ermx8
    @ermx8 Před 8 lety +24

    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.

    • @rohanpatil8417
      @rohanpatil8417 Před 6 lety +15

      He Studied at Indian Institute of Information Technology!

  • @418aditya3
    @418aditya3 Před 4 lety +1

    The way you are explaining is absolutely brilliant. Even our professors won't even know the names of what you are telling..🙏🙏

  • @HrishikeshMahajan007
    @HrishikeshMahajan007 Před 4 lety +1

    Shame on the 52 people who disliked. Such great content and explanation deserves credit. Good work Animesh.

  • @gucluceyhan
    @gucluceyhan Před 8 lety

    It is so sad and so unfortunate that I found your lessons yesterday.
    They are pure jewel. Thank you...

  • @DaveJLin
    @DaveJLin Před 6 lety +25

    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!

    • @marcelalves6196
      @marcelalves6196 Před 5 lety +8

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

    • @shreyashchauhan8567
      @shreyashchauhan8567 Před 4 lety +1

      Can you elaborate more please

    • @monikaparmar2061
      @monikaparmar2061 Před 4 lety

      @@marcelalves6196 Thanks very much. This is really helpful.

  • @katiemartinez772
    @katiemartinez772 Před rokem

    I cannot explain how much I love you. Thank you so much! Your explanations are the best.

  • @ShivamKendre-fc3su
    @ShivamKendre-fc3su Před 4 lety

    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.

  • @thisaintmyrealname1
    @thisaintmyrealname1 Před 7 lety +1

    Excellent Teacher. I totally admire you. Thanks for this amazing material!

  • @ajinkyakirkire6561
    @ajinkyakirkire6561 Před 4 lety +2

    That's the best I've ever understood call by reference in 4 years of learning c++

  • @coin5207
    @coin5207 Před 3 lety +1

    Your precise explanations are putting collage professors to shame! Kudos to you

  • @mrkalykuuber
    @mrkalykuuber Před 8 lety +15

    this how the great teacher is ,, thanks alot

  • @ranavivek819
    @ranavivek819 Před 9 lety +1

    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

  • @BhargabKakati
    @BhargabKakati Před 7 lety +1

    Trying to transform from an Albert to a programmer.Thank you so much.cleared the concept

  • @mdabusayeed2305
    @mdabusayeed2305 Před 6 lety

    Tough topics get easy: One of the best video lecture series I ever had

  • @stickydamper
    @stickydamper Před 4 lety +18

    Rest in peace brother, your legacy lives after you :-(

    • @rickyruan6230
      @rickyruan6230 Před 2 lety +1

      I am sry, may I know what's going on with this great professor?

    • @ighsight
      @ighsight Před 2 lety +5

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

    • @efurudesigns
      @efurudesigns Před rokem +2

      Omg! my heart breaks! , God! Rest in peace such a great teacher 😢❤

  • @samdavepollard
    @samdavepollard Před 3 lety

    I have several books on C, including those that are top rated on amazon.
    These videos beat them all.
    Exceptionally useful. Thank You.

  • @inclinedscorpio
    @inclinedscorpio Před 5 lety +5

    *Most of us were unclear of the fact what we actually want which was cleared after watching your MASTERPIECE.*

  • @sriramhariharan8448
    @sriramhariharan8448 Před 9 měsíci

    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!!

  • @thekrazystuff5807
    @thekrazystuff5807 Před 3 lety

    This is the first time I understood what exactly call by reference is .... thank you so much.
    Subscribed You

  • @ahmadfaiq85
    @ahmadfaiq85 Před 4 lety

    Very clear and extensive explanation. Thank you for your work.

  • @omerpalabiyik
    @omerpalabiyik Před 2 lety

    I don't really comment that much, but this is pure perfection!!! RIP Harsha

  • @micado88
    @micado88 Před 11 lety

    The best call by reference explanation indeed ... the memory showing method is very helpful
    thanks!

  • @adityamali1862
    @adityamali1862 Před 5 lety

    You are the best teacher ive ever met...

  • @rhythmsharma4561
    @rhythmsharma4561 Před 6 lety

    Thanks to you, now i understand concept of pointer, call by reference and call by value

  • @lindsey5236
    @lindsey5236 Před 5 lety

    You are awesome man !!! best tutorial of pointer ever , thank you so much for making it !!

  • @Priyanka-rl7hk
    @Priyanka-rl7hk Před 7 lety

    you are really great.... thank you very much....the way you explain is really awesome....faculties from renowned institute should learn from you

  • @lighttangerinesky
    @lighttangerinesky Před 9 lety +1

    These are very helpful! Thank you so much!

  • @CodeRCreatives
    @CodeRCreatives Před 3 lety

    the best channel on CZcams for learning

  • @TheFlyguy31
    @TheFlyguy31 Před 9 lety

    Thank you...i have written it as you explained it..Great lesson!

  • @AshutoshKumar-mv5um
    @AshutoshKumar-mv5um Před 6 lety

    Bhaiiiiiiiii great piece of knowledge

  • @vikaspatel3994
    @vikaspatel3994 Před 9 lety +1

    Amazing Explaination..............like a c in sea...............Thanks a lot.........fan of u

  • @mohanaddarwish2307
    @mohanaddarwish2307 Před 8 lety +4

    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 >.

  • @henokweldemicael
    @henokweldemicael Před 9 lety

    You sir are AWESOME! Why cannot my professors explain it like this? They just over-complicate it took sophisticated!

  • @narendra564
    @narendra564 Před 6 lety

    This is the best explanation I got, Thank you.

  • @nipundhananjaya1367
    @nipundhananjaya1367 Před 7 lety

    oh,,,, thank you very much ! very clear explanation. the best explanation i have ever seen ... good luck and keep up!

  • @mycodeschool
    @mycodeschool  Před 11 lety +4

    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.

  • @JohnnyFive
    @JohnnyFive Před 10 lety

    Thank you so much. You did a wonderful job explaining this.

  • @wormoSTEEZE
    @wormoSTEEZE Před 7 lety

    thank you, very informative and helped me understand a lot of important things.

  • @HarmanChahal09
    @HarmanChahal09 Před 7 lety +1

    @mycodeschool which ide or compiler of which version you are using bro please give complete details . thanks in advance you are the best .

  • @abhishekpai
    @abhishekpai Před 5 lety

    Superb video!!! Loved it. Beautifully explained👍👍

  • @kristinashiryaginasalini1626

    Thank u very much ! With ur video it's easy to understand difficult things!

  • @TEXAS2459
    @TEXAS2459 Před 9 lety +4

    wow i cant believve i am still going into further depth......nice tutoring mannn......

  • @urdev65
    @urdev65 Před 7 lety +1

    i finally understand why indians are so good at programming, because their teachers teaching skills are far more better than our's.

  • @rearea784
    @rearea784 Před 7 lety +4

    I like Albert's adventures in programming :)

  • @victorlazarus5221
    @victorlazarus5221 Před 7 lety

    thank u very much sir for the series! The best explanation.. Awesome...u made my concepts damn clear.. :)

  • @rahul930
    @rahul930 Před 7 lety

    This is best...I think, even paid tutorials are not as good as this......Thanks a lot man....:)

  • @radiator007
    @radiator007 Před 8 lety

    Awesome explanation to a difficult topic.. Thank you sir.

  • @leonperianu7684
    @leonperianu7684 Před 5 lety

    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:)

  • @upmabaranwal5672
    @upmabaranwal5672 Před 7 lety

    very very helpful and ur explanation method is unbelivable

  • @ramyak953
    @ramyak953 Před 6 lety

    thanks for this beautiful video , I m going into deep day by day!!!!

  • @damoimyers2651
    @damoimyers2651 Před 4 lety

    At least someone can explain it so I can understand.... Thanks bro!

  • @vijayank3207
    @vijayank3207 Před 9 lety +1

    very clear explanation sir..thank you soo much

  • @karankashyap-do7sk
    @karankashyap-do7sk Před 7 lety +1

    I love u brother

  • @ramkumarrammohan3745
    @ramkumarrammohan3745 Před 7 lety

    Very awesome explanations. Thank you.

  • @chuckyb9469
    @chuckyb9469 Před 4 lety +12

    " Albert writes a simple code "
    That's simple code? damn Albert!

    • @elie933
      @elie933 Před 2 lety

      you still haven't seen anything

  • @adityaprakash7355
    @adityaprakash7355 Před 7 lety

    bro im doing pg dac course through cdac chennai and i find your lectures very usefull

  • @sadaffatima2076
    @sadaffatima2076 Před 4 lety

    Ultimate..ur explaination is awesome

  • @nirmalamanthngauda1517

    Ty Sir,U really taught very well,awesome explanation

  • @pathruduchintakayala4513

    +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....

  • @reubenfernandes5263
    @reubenfernandes5263 Před 10 lety

    m preparing for my exams.....that was a lots of help.....thanks

  • @MOHANSUEC
    @MOHANSUEC Před 5 lety

    Great stuff man!!
    hats off!!!!

  • @greegeo
    @greegeo Před 3 lety

    THANK YOU! exactly what I was looking for

  • @aungthiha9443
    @aungthiha9443 Před 3 lety

    Thanks sir .
    You are the best teacher in the world.

  • @saadnnoor
    @saadnnoor Před 9 lety

    thaks!! your videos are just too good!! want more about java and adroid!! :)

  • @VaishaliGoyal49
    @VaishaliGoyal49 Před 7 lety

    U explain really well! Thanks a lot :)

  • @patrasculucian2403
    @patrasculucian2403 Před 6 lety

    Stunning tutorial!

  • @venkatarulprakasam3035

    best explanation to understand pointers!!

  • @magdalenagrzenkowicz4010
    @magdalenagrzenkowicz4010 Před 7 lety +1

    Thanks! This is incredible! :)

  • @ming9630
    @ming9630 Před 4 lety

    Thank you very much for your explanation! You rock!