How To Return An Array From A Function | C Programming Tutorial

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Neat. I think of it as two opposing thought-processes:
1. This function returns an array.
2. This function is given an array to write to.

rabbitcreative
Автор

I'm learning C again after some years, so glad this channel exists because the teachings are super clear to me

siya.abc
Автор

I have 10 years of Experience in C Programming. I have never Seen such Clear Explanations in the entire you tube. Thanks to Portfolio Courses. You are really Awesome.

neelakantannilakantanswami
Автор

When passing a pointer to an array, please don't forget to pass the number of items that has the array, otherwise you might access memory outside of the array and have segfault. The example in the video implies that the array length is 5 so it's hardcoded everywhere and there's no issue here.

fxs
Автор

I think more important for the _static_ approach is, that every function call will reference the *same* array.

So when you call set_array(4) and later on set_array(5), the first array will be changed too.
That produces very hard to find bugs because of the sideeffects.

A topic that would be great for another video.

hansformer
Автор

I’m a bit disappointed that you didn’t put more emphasis on properly pairing up malloc and free calls. In my experience it helps putting both in the same scope. So in your example one would move the malloc call out of the function and into main.

trg
Автор

Watching those great videos more than once will make you a better programmer.

fifaham
Автор

Thank you!! Theese videos are filling big gaps in youtube!

ellipszia
Автор

I'm not regular C programmer but i'm old enough to touch it and i say, *very* clear explanations of some C quirks, wich can let some one really undrestand what is going on.
Thank you and keep going!

AK-vxdy
Автор

Great explanation, particularly the inclusion of static local variables which are encapsulated but not dynamic... Nice Work

davidharper
Автор

Educational videos like those, of Kevin, are very hard to find anywhere, not even in the universities. Kevin deserves a lot of appreciation.

fifaham
Автор

bruh, I've been looking for this for an absurd amount of time, this is much easier than messing with static ints' and those sorts of things..

poenanster
Автор

8:00 congratulations! you reinvented memset() ;-)

yxyk-fr
Автор

The huge disadvantage of the static approach is that the same array is shared between the calls. That means that if you call the function twice with different values, the values of the first array will be changed to the new value during the second call (because both have the same address)

TheKhalamar
Автор

🎯 Finally some clarity on static vs dynamic allocation. 👍👍

lucasgroves
Автор

I needed this video 😭 strings and arrays in C are killing me

ejimenez
Автор

somehow i expected that the technique would also be mentioned, but whatever 😂

HoSza
Автор

you are the best Sirrrr, nobody like you taught me these concept, plz carry on your way of teaching is unbelievable . i have huge respect for u sir.please don't leave us in this journey.
Thanku sir🙂

RaviKumar-ghoh
Автор

Man you just saved me because there are no videos about it on Youtube. Man, thank you very much (I'm in physics, in the third year) ;)

oracle_stm
Автор

I love these videos. Great content, and beautiful explanations. The only nit I have is where the pointer indicator is...I always read it as the dereference operator when it is next to the name of the thing it refers to. (Sorry, don't flame me)

johndubchak