This is genuinely the best C language tutorial channel in KZbin.
@mikehibbett33019 ай бұрын
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
@SketchupGuru2 жыл бұрын
Very useful video btw.. Whenever I get stuck with the cs50 course, i come running to your videos, gain clarity and then rewatch the cs50 content to cement the idea.. If i ever make a how to learn code video, im going to include your channel in it
@PortfolioCourses2 жыл бұрын
Thank you very much, I'm so glad to hear these videos help to clarify what is in the CS50 content. :-)
@naboulsikhalid7763 Жыл бұрын
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
@PortfolioCourses Жыл бұрын
You're welcome Naboulsi, and thank you for the kind feedback! :-)
@Bayanii1772 Жыл бұрын
this channel is underrated
@PortfolioCourses Жыл бұрын
Thank you for the support Bayan! :-)
@Bayanii1772 Жыл бұрын
@@PortfolioCourses Update, I got an A+ on my C programming course. Honestly, your C programming examples playlist helped me a lot with saving time and getting straight to the point, unfortunately lots of free sources tend to lack quality.
@PortfolioCourses Жыл бұрын
@@Bayanii1772 That's awesome, congratulations!!!! 😀🥳 I'm so glad to hear the playlist was able to help you out, thank you for taking the time to share this with me!
@lucasgroves137 Жыл бұрын
🎯
@lucasgroves137 Жыл бұрын
@@Bayanii1772 Lol, that's generous. In this age of garbage, nothing is more common than describing products/services/content/anything at all as _excellent_ when they are consistently mediocre or worse. It's mind-blowing.
@Brad_Script5 ай бұрын
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)
@LeeHongYee9910 ай бұрын
So effectively, array as argument in function is really passed by reference.
@john.darksoul9 ай бұрын
If you have to pass an array to a function, it would be best (if you're not using a struct wrapper) to use foo(size_t size, T array[static size]); to communicate your intentions to whoever is reading your code, as well as to provide the compiler additional info. For passing a pointer to a single value, use foo(T ptr[static 1]); which will allow the compiler to issue warnings if NULL is passed to this function. Iirc, 'T ptr[static N]' means that ptr points to at least N valid objects of type T.
@xCwieCHRISx9 ай бұрын
If u pass a array as an argument or return an array, it is basically the same as passing/returning a pointer. I personally never use array as arguments or return value, I just use pointer. I never saw someone use "T array[size]" as an argument, but "T *array" and "size_t size" as additional argument is pretty common. Just use arrays for allocating an array on that stack. For the rest treat array as a pointer, except for indexing maybe (arr[i] is more simple than *(arr+i) ). Passing arrays around is just confusing in my opinion, when it basically behaves like a pointer.
@a.v799811 ай бұрын
Brillian tutorials!
@hazemba26692 жыл бұрын
Thank you for this amazing explanation! 🤩
@PortfolioCourses2 жыл бұрын
You're welcome Hazem! :-)
@Acksakal Жыл бұрын
Good day, Mr. Teacher. I got 2 questions: in your video example with arrays how can I a star pointer "*" work without an ampersand "&"? This is the second time I've seen it. First one was this: int main() { char str[] = "All the world's a stage, and all the men and women merely players"; int size = strlen(str); //determining string's length printf("Old line: "); //print the first word char sep [10]=" "; char* words= strtok (str,sep); //why is star required here? printf("The first word is: %s ", words); return 0; } Why do we need to use "*" after char and how come does it work w/o an ampersand? Hope you'll help =)
@PortfolioCourses Жыл бұрын
This video might help to explain the difference: kzbin.info/www/bejne/h6GWiJSqgbGSfsU. And this video on pointers too, char * is a pointer type variable: kzbin.info/www/bejne/aHinmot9areZhKc. :-)
@yunustan7502 Жыл бұрын
Nice and clear explanation. Thank you.
@PortfolioCourses Жыл бұрын
You're welcome, I'm glad you enjoyed it! :-)
@flywittzbeats4008 Жыл бұрын
Incredible stuff. Thank you so so much!!!
@PortfolioCourses Жыл бұрын
You're welcome, I'm glad you enjoyed it! :-)
@mikehibbett33019 ай бұрын
And of course that pointer is to a variable on the stack, so it wont be around for long :)
@heshamgad-yh9vs Жыл бұрын
Dude, you are awesome
@ddlc70226 ай бұрын
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
@ddlc70226 ай бұрын
Is it Code::Blocks ?
@SketchupGuru2 жыл бұрын
I'm assuming it's going to be the same for strings. We pass memory addresses aka pointers in string as well?
@PortfolioCourses2 жыл бұрын
Yes that's correct, what's really being passed is a pointer (i.e memory address). :-)
@hyperphenomenal4360 Жыл бұрын
extremely useful thank you so much
@PortfolioCourses Жыл бұрын
You're welcome! :-)
@SketchupGuru2 жыл бұрын
What if you return x; in the add function? Wouldn't that be carried to the main function
@PortfolioCourses2 жыл бұрын
Yes, we could return a value to the main function with a return statement, and then perhaps assign the value to the variable a. :-)
@franciscojusto4744 Жыл бұрын
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
@PortfolioCourses Жыл бұрын
Can you show me the code that you're using to print out these values so I can be sure what is going on? You can just paste it in a comment/reply. :-)
@franciscojusto4744 Жыл бұрын
@@PortfolioCourses int array[] = {5}; printf("address of array: 0x%p ", &array); printf("address pointed by array: 0x%p ", array); printf("array[0] address: 0x%p ", &array[0]); so i must have made a mistake somewhere before because now its working as i expected it to work! sorry for the confusion!! 😅 thank you for the quick reply!
@PortfolioCourses Жыл бұрын
No worries, glad you got it sorted out! :-)
@franciscojusto4744 Жыл бұрын
@@PortfolioCourses I just wanted to say thank you for all your effort towards your long list of comprehensive videos on C! I have been whatching them for a while now and i find it more useful to me to come here everytime i need a refresher or i nneed to understand something, rather than going on a wild search for answers. This last weekend when i posted my question i was studying various topics for an interview that took place monday. I based my study mostly on your videos because YES, they are that good! :) I'm happy to say that you helped me to better prepare myself for the interview and that i got a job position in said company for C in aeronautics. Again, I think mostly anyone who comes across your channel and your tutorials on C agrees with me when i say they are very well made and they are a great source of information and learning. So thank you dearly for all your work!
@PortfolioCourses Жыл бұрын
@@franciscojusto4744 WAHOO congratulations Francisco, I'm so happy to hear that!!! 😀
@mahmoudelhanafy89 Жыл бұрын
what if i want to make operations at all array elements. should i use for in the function ???
@PortfolioCourses Жыл бұрын
Yes, using a loop like a for loop or while loop would be a good idea. :-)