Pass By Reference | C Programming Tutorial

Тәжірибелік нұсқаулар және стиль

An overview of pass by reference in C (sometimes also called call by reference). More accurately we can call this "pass by pointer", but pass by reference is the more common terminology. Source code: github.com/portfoliocourses/c.... Check out www.portfoliocourses.com to build a portfolio that will impress employers!

Пікірлер: 39

  • @crklopotic
    @crklopotic4 ай бұрын

    Pointers can be hard to learn and understand why or when to use them. This is a nice short video that clearly articulates all the basics in a very clear and easy to follow along example. Thanks for all the videos! Very well done.

  • @pietraderdetective8953
    @pietraderdetective89536 ай бұрын

    i absolutely love this C tutorial series. your channel is amazing! i need to pick up the pace, i still got 154 videos left to grind..

  • @PortfolioCourses

    @PortfolioCourses

    6 ай бұрын

    I’m really glad that you’re enjoying the content. :-)

  • @philipphortnagl2486
    @philipphortnagl2486 Жыл бұрын

    This concept is hard to get for beginners, thanks a lot!

  • @PortfolioCourses

    @PortfolioCourses

    Жыл бұрын

    You're very welcome Philipp! :-)

  • @calvinalberts5119
    @calvinalberts51198 ай бұрын

    Watched so many videos on this. First time I actually understood what it is. Good video.

  • @user-lf3yj5zb2r
    @user-lf3yj5zb2r2 жыл бұрын

    Passed by pointer. Got it!!! Great video, thanks!

  • @PortfolioCourses

    @PortfolioCourses

    2 жыл бұрын

    You're welcome! :-D

  • @christopheanfry2425
    @christopheanfry24252 ай бұрын

    This is gold!!! Thank you for the clear explanation

  • @PortfolioCourses

    @PortfolioCourses

    2 ай бұрын

    You're very welcome! :-)

  • @SuperDamuho
    @SuperDamuho2 ай бұрын

    I get it now. Pass by reference (pointer) is needed because the variables in functions are exclusive. It's like there's a wall between the function area and the main area. The only way we can connect those variables (in main and in function) is to manipulate the memory via addresses. Kinda like digging a hole underground.😄

  • @louisdzidzor2253
    @louisdzidzor2253 Жыл бұрын

    The Best channel so far

  • @PortfolioCourses

    @PortfolioCourses

    Жыл бұрын

    Thank you very much Louis! :-)

  • @love15.01
    @love15.012 жыл бұрын

    really good, thanks you!:)

  • @PortfolioCourses

    @PortfolioCourses

    2 жыл бұрын

    You're welcome! :-)

  • @nano0110
    @nano0110 Жыл бұрын

    Got it ! thank you a lot !

  • @PortfolioCourses

    @PortfolioCourses

    Жыл бұрын

    Excellent, and you're welcome! :-)

  • @gamingwithronpubgm3615
    @gamingwithronpubgm36158 күн бұрын

    thx man I immediately understood everything after watching this video😁

  • @kierkegaard54
    @kierkegaard546 ай бұрын

    Clear as a whistle

  • @muhisaleh4598
    @muhisaleh4598 Жыл бұрын

    pass by pointer 💪thnx a lot, this channelis realy one of the best c channel ever :)

  • @PortfolioCourses

    @PortfolioCourses

    Жыл бұрын

    Haha thanks I'm glad you think so Muhi! :-)

  • @yoeurnyan1839
    @yoeurnyan1839 Жыл бұрын

    thank you do much such a great video.

  • @PortfolioCourses

    @PortfolioCourses

    Жыл бұрын

    You're welcome Yoeum, I'm glad you enjoyed it! :-)

  • @L00p69
    @L00p6910 ай бұрын

    Really thanks ❤

  • @PortfolioCourses

    @PortfolioCourses

    10 ай бұрын

    You’re welcome! ❤️

  • @bougsqf4462
    @bougsqf44622 жыл бұрын

    cool man! thx

  • @PortfolioCourses

    @PortfolioCourses

    2 жыл бұрын

    You’re welcome! :-)

  • @Andy_B.
    @Andy_B.2 ай бұрын

    still didnt understand why call by value didn't work... 😆 but I understood the call by reference mechanism, thanks!!

  • @guusziin6241

    @guusziin6241

    Ай бұрын

    because in C apart from global variables all variables only exist inside the scope of a function. in the example of the video x and y only exist inside the main function and when you pass their values to the swap function it will actually create a copy of them that only exist inside swap, and when the swap function ends the copy will be deallocated and will return to the main function where the actual x and y remained unchanged. so when you actually pass the addresses of x and y as an argument of swap it'll change their values for the whole program, because the actual value stored in the memory address of x and y will be changed other than a copy that only exists in the scope of swap

  • @nuclearrambo3167
    @nuclearrambo3167 Жыл бұрын

    if we think that & is inverse of *, & times * will produce 1. Therefore *&x = x. (i dont know is that interpretation whether correct or not)

  • @stoic5497

    @stoic5497

    3 ай бұрын

    No

  • @ridoxi4341
    @ridoxi4341 Жыл бұрын

    what IDE you're using sir? and thanks for the video.

  • @PortfolioCourses

    @PortfolioCourses

    Жыл бұрын

    You're welcome! :-) In this video I am using Visual Studio Code as a text editor, and I am using the gcc compiler on the MacOS Terminal.

  • @jonathanmoore5619
    @jonathanmoore5619 Жыл бұрын

    Can you have (int &a, int &b) as function perameters? Im confused here? As we want an address to deference...?

  • @PortfolioCourses

    @PortfolioCourses

    Жыл бұрын

    We can do that in C++ where reference variables are supported. But in C we can only achieve 'pass by reference' by using pointer parameters. When we have a parameter like int *a, the argument is going to be a pointer (memory address). :-)

  • @brunomartel4639
    @brunomartel4639 Жыл бұрын

    why is it called passed by pointer and not passed by reference?

  • @PortfolioCourses

    @PortfolioCourses

    Жыл бұрын

    Great question Bruno! :-) The term pass by reference is more accurate in languages like C++ that have reference variables (and reference parameters): kzread.info/dash/bejne/layt1beJiqucZbw.html. Reference variables are a different type of variable than a pointer, though the concepts are a bit similar too... references are a reference to the variable, the essentially "are" the variable they are referencing and give us access to that variable. Whereas pointers store a memory address, the memory address of the variable they are "pointing to", and we can access the variable they are "pointing to" by de-referencing the pointer. So in C, because we are using pointers, it's more accurate to say "pass by pointer". As a practical matter though if you say "pass by reference" when referring to "pass by pointer" people will know what you mean and the terms get used in a more casual manner like that in practice.

Келесі