Passing an Array to a Function | C Programming Tutorial
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!
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
Very useful video btw..
this channel is underrated
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)
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
Thank you for this amazing explanation! 🤩
Brillian tutorials!
Dude, you are awesome
Incredible stuff. Thank you so so much!!!
Nice and clear explanation. Thank you.
So effectively, array as argument in function is really passed by reference.
If you have to pass an array to a function, it would be best (if you're not using a struct wrapper) to use
extremely useful thank you so much
Perfect 👍🏻
Good day, Mr. Teacher.
Excellent =)
I'm assuming it's going to be the same for strings. We pass memory addresses aka pointers in string as well?
And of course that pointer is to a variable on the stack, so it wont be around for long :)
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
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