Passing an Array to a Function | C Programming Tutorial

Sdílet
Vložit
  • čas přidán 28. 06. 2021
  • An overview of passing an array to a function in C and what's really going on when we do! Source code: github.com/portfoliocourses/c.... Check out www.portfoliocourses.com to build a portfolio that will impress employers!

Komentáře • 49

  • @mikehibbett3301

    I'm lucky enough to have come to C from assembler, so I intuitively know about local variables being on the stack, and parameters passed through registers. I hope modern teachers make this clear. Funny enough, I learned this as a hobbyist as a kid before going to university to learn computer science

  • @SketchupGuru
    @SketchupGuru Před rokem +15

    Very useful video btw..

  • @Bayanii1772
    @Bayanii1772 Před rokem +12

    this channel is underrated

  • @Brad_Script
    @Brad_Script Před 14 dny

    another way to prove it is with the sizeof operator, if you use sizeof on an actual array it will return the number of bytes of the array, if you use sizeof on an array that is a function parameter, it will return 4 or 8 (size of a pointer)

  • @naboulsikhalid7763
    @naboulsikhalid7763 Před rokem +1

    Huge appreciation, I feel the effort to explain the topic, because you know it's confusing and it needs more attention and extra explanation. Thank you a lot. If I meet in this life: I will give you a BIG HUG

  • @hazemba2669
    @hazemba2669 Před rokem +2

    Thank you for this amazing explanation! 🤩

  • @a.v7998

    Brillian tutorials!

  • @heshamgad-yh9vs

    Dude, you are awesome

  • @flywittzbeats4008
    @flywittzbeats4008 Před rokem

    Incredible stuff. Thank you so so much!!!

  • @yunustan7502

    Nice and clear explanation. Thank you.

  • @LeeHongYee99

    So effectively, array as argument in function is really passed by reference.

  • @john.darksoul

    If you have to pass an array to a function, it would be best (if you're not using a struct wrapper) to use

  • @hyperphenomenal4360

    extremely useful thank you so much

  • @emtnan1733
    @emtnan1733 Před rokem

    Perfect 👍🏻

  • @Acksakal

    Good day, Mr. Teacher.

  • @user-lf3yj5zb2r
    @user-lf3yj5zb2r Před 2 lety

    Excellent =)

  • @SketchupGuru
    @SketchupGuru Před rokem

    I'm assuming it's going to be the same for strings. We pass memory addresses aka pointers in string as well?

  • @mikehibbett3301

    And of course that pointer is to a variable on the stack, so it wont be around for long :)

  • @franciscojusto4744
    @franciscojusto4744 Před rokem

    so i have a question. when i print out the array by itself by using the %p specifier i get a memory address being pointed by the array. and when i use the %p in conjuction with &array i get the memory address of where the array variable is stored. then i use the %p for array[0] and i get yet another address. i thought the address pointed by array would be the first element of the array but it is not? this raises the question of why is there an intermediate address between the value stored in array (address) and the first element of array (address). sorry for the long question! Love your videos <3

  • @ddlc7022

    What is the editor you are using ? I can see the name is Code ? But when I look for Code for Mac, I only get Visual Studio Code results