array vs &array Pointers Difference Explained | C Programming Tutorial

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

This video is a must-watch for any C programmer. The concept of arrays vs pointers, the decaying of arrays into pointers and how everything is handled in memory is crucial in understanding C.

thanostzia
Автор

This guy is an absolute legend. Just when i though i had mastered pointers, the concept manages to leave me bamboozled again. Thank you for your amazing work! ❤

succerzxix
Автор

really good video. really helpful how you formatted the print statements so that everything was in line. You do the small things really well.

armanlodhra
Автор

This is the first channel I look at when there is something I don't understand about the subject.I can find everything I'm looking for, even what I'm not looking for 😄. Thank you for such valuable information. 😊

justwalk
Автор

Every small detail about c is crystal clear here in this channel..Keep it up bro...

infas_mhd
Автор

Mr. all of your videos are 100% understandable unlike lecturers at my university. well done !

duldulatori
Автор

One day, not today, but one day I will learn how to speak as cohesive, clear and straight-to-the-point as this gentleman.

abraham
Автор

passed all the morning watching videos on array dacay on other guys' "famous" channels, BUT your explainations are ALWAYS the best, precise, concise, starting from scratch and working up. GREAT WORK!

emme
Автор

Your explanation is the best explanation I've ever seen. I grasped so many things from your videos and I am still watching them; thanks a million Dr Kevin.

MA
Автор

Your programming language tutorials are one of best on YT, amazing job!

avixx
Автор

I made some tests about pointers and pointers to an entire array, and I found that if you dereference a pointer to an entire array like a int (*)[5], it will obtain a pointer int * to the first element on this array pointer. So that's why in 11:00 momment was printed an adress. To get the correct behaviour, you need to add an extra dereference operator *, and the line will be:
printf(" **(matrix[1] + 1): %zu\n\n", **(matrix[1] + 1));

So the dereference order stays:
int (*)[5] -> int * -> int
Which is similar to:
int ** -> int * -> int
But the int ** and int (*)[5] types aren't interchangeable

Curiosity:
The names of a N-Dimensional matrix decay to pointers to an entire first (N-1)-Dimentional Array of the N-Dimensional Array, excluding the n = 1 case.
Then we have:
int array1[5]; //1D
int array2[5][5]; //2D
int array3[5][5][5]; //3D

Therefore:
array1 decays to a int * to the first element. This case is exclusive to the rule.
array2 decays to a int (*)[5] to the first row of the matrix, and a row is a 1D array.
array3 decays to a int(*)[5][5] to the first 2D matrix of the 3D matrix.

Another Curiosity:
If you use the reference operator & in a matrix instead of either a matrix row or in a vector, you will obtain a pointer to an entire matrix, and the type stays something like int (*)[3][5], and the order of the dereference stays:
int (*)[3][5] -> int(*)[5] -> int * -> int
And the detail is that these operations, all of them, returns the first element, row or matrix of the array referenced. Then if I have a 3D multidimensional like this:
int matrix[5][5][5];

&matrix -> pointer to the entire 3D matrix
&matrix[0] -> pointer to the FIRST 2D matrix in the 3D matrix
&matrix[0][0] -> pointer to the FIRST ROW in the FIRST 2D matrix in the 3D matrix
&matrix[0][0][0] -> pointer to the FIRST ELEMENT in the FIRST ROW in FIRST 2D matrix in the 3D matrix.

Rafael-fpxc
Автор

For C language, this has to be the go to channel. Period!
Thanks a ton! Sir!

mango-opinions
Автор

Thanks for explaining array decay to pointer. Best explanation I've come across. Better than any book. Cheers! Liked and subbed

mehtubbhai
Автор

Been a minute since I’ve worked with memory/C, this was immensely helpful and probably saved countless hours. Thanks!

kitchenchem
Автор

With just this one video, you throw a clear examole of an" ideal teacher with a great depth of knowledge about every single concept".Sir, PLEASE PLEASE MAKE a Playlist for DSA as it is absolutely crucial and difficult.
A teacher like you ought to teach such critical concepts, kindly understand. Thank you soooo much for the videos and hope you do a dsa course for us needy.

nukarajupavani
Автор

It is a great relief to watch this video made by someone who truly understands the concepts!

(This video was recommended to me after two greatly confused videos on this topic by "Code with Huw" managed to frustrate me to no end. He starts out with the intention to address the misconception that an array in C is a pointer, and ends up arguing that an array in C is an address....lol?)

ronald
Автор

I've spent days trying to find a resolution to my confusion, in differentiating 'array' and '&array'. This video was extremely helpful, subbed.

R_C
Автор

Very interesting explanation. I studied C very long years ago, your videos are great refresh to details many programmers don't pay attention to. Thank you Kevin.

fifaham
Автор

I think this videos is showing the differences between arrays and pointers in C quite well.
It also gets real quirky when you add memory areas you got with malloc and treated like an array to the mix

hansdampf
Автор

I love your videos going full c and your videos help me so much to understand these tricky concepts. Thanks again 🙏

christopheanfry
join shbcf.ru